Commit Graph

3839 Commits

Author SHA1 Message Date
Valentin Lorentz
8f001f8045 Check spec.loader is not None when importing a plugin. 2020-02-09 16:02:35 +01:00
nyuszika7h
0f3264cf26 Add modulo operator to new math evaluator
Closes #1402.
2020-02-08 16:08:23 +01:00
opal hart
f24a17e5c4 Config docs: remove reference to grouped nicks
Some networks (e.g. freenode) now allow usage of grouped nicks for SASL
username
2020-02-08 11:07:19 +01:00
Valentin Lorentz
a6ae9f51a3 ChannelStats: Use the safe math evaluator. 2020-01-26 20:42:55 +01:00
Valentin Lorentz
99dd6f1506 core/Math: Move the math evaluator to src/utils/.
It will be used by ChannelStats.
2020-01-26 20:42:55 +01:00
Valentin Lorentz
9ab908759a Use importlib instead of imp.
importlib is deprecated.
2020-01-26 12:00:08 +01:00
Valentin Lorentz
9891b0fca4 Replace failUnless/failIf with assertTrue/assertFalse.
The old names are deprecated.
2020-01-26 11:14:18 +01:00
Valentin Lorentz
5efd2afa27 Socket: Don't add instances twice in cls._instances.
The connect() method already adds it, so it was in the list twice
(added both by __init__() and connect()).

This caused _select() to call _read() twice on the same instance,
except there is usually nothing to read on the second call,
so it blocks for up to conf.supybot.drivers.poll().
2020-01-25 21:00:42 +01:00
Valentin Lorentz
777d8e4920 Socket: use a proper lock instead of a boolean. 2020-01-23 16:47:49 +01:00
Valentin Lorentz
e7553dcca4 Add subcommand dispatching for CAP/FAIL/WARN/NOTE. 2020-01-23 14:25:10 +01:00
Valentin Lorentz
c4d073a9be Rename doAuthenticate* functions to not conflict with callback names. 2020-01-23 14:24:41 +01:00
Valentin Lorentz
32d8d141ad Make irc.error do nothing is no string is given as argument.
Fixes c1d3bad64f, which crashed with:

```
ERROR 2020-01-18T01:34:07 Uncaught exception in NickAuth._callCommand:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/supybot/callbacks.py", line 1337, in _callCommand
    irc.errorNoCapability(cap)
  File "/usr/local/lib/python3.7/dist-packages/supybot/callbacks.py", line 544, in errorNoCapability
    raise Error()
supybot.callbacks.Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/supybot/log.py", line 368, in m
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/supybot/callbacks.py", line 1359, in _callCommand
    irc.error(str(e))
  File "/usr/local/lib/python3.7/dist-packages/supybot/callbacks.py", line 1065, in error
    raise ArgumentError
supybot.callbacks.ArgumentError
```
2020-01-18 11:04:54 +01:00
Valentin Lorentz
895881e66e Call super().setValue() before defaultHttpHeaders.
To prevent infinite recursion on startup, because defaultHttpHeaders
gets the value; which is unset, so 'registry._lastModified > self._lastModified'
is True, so .set() is called, so .setValue() is called again.
2020-01-17 19:49:16 +01:00
Valentin Lorentz
c457b52067 Deduplicate setting Accept-Language HTTP header.
This adds a new function conf.defaultHttpHeaders that can be used by plugins
to get all the default HTTP headers for a given network/channel.
2020-01-14 19:03:12 +01:00
Tasos Sahanidis
62f8b47e61 Add supybot.protocols.http.requestLanguage 2020-01-14 18:48:11 +01:00
Tasos Sahanidis
7bd68df8aa Fix getSpecific usage
The channel and network arguments were incorrectly swapped
2020-01-12 10:35:35 +01:00
Valentin Lorentz
0fccea30ce Import MutableMapping and MutableSet from collections.abc.
Aliases in collections itself are removed in 3.8.
2020-01-09 01:11:12 +01:00
Valentin Lorentz
ac07b440dc Rewrite ecdsa-nist256p-challenge using python-cryptography instead of python-ecdsa.
Which is more secure. Closes GH-1389.

It also fixes the protocol/format to use the same one as Atheme.
See also: 8a81224ba8
2020-01-01 12:07:59 +01:00
James Lu
a6392c8582 test: choose a random free port for tests using the HTTP server
Closes #1392.
2019-12-15 20:20:37 +01:00
Valentin Lorentz
a86df1fc35 Remove dead code from Group that belongs in Value. 2019-12-09 21:27:09 +01:00
Valentin Lorentz
83114e5fbd src/callbacks.py: use network-specific values.
Closes GH-1393
2019-12-05 21:51:25 +01:00
Valentin Lorentz
1ed47f802f Request msgid capability. 2019-12-05 21:11:35 +01:00
Valentin Lorentz
a1ee580d08 Make getLocaleFromRegistryCache reload existing locales.
The core locale is loaded before this function is called, so it needs to
reload it for non-en locales to be loaded.
2019-11-24 12:59:38 +01:00
Valentin Lorentz
63b0d7e653 Update core fr translation. 2019-11-24 12:47:03 +01:00
Valentin Lorentz
0828b207be Add fallback if getting supybot.language from registry cache failed. 2019-11-24 12:46:10 +01:00
Valentin Lorentz
423a38770b Get locale name on startup from registry cache instead of parsing config file.
Parsing the config file needlessly requires an extra read of it,
and is brittle (extra spaces, etc.)
It was especially broken as there was a newline character
at the end of currentLocale, which made everything fail
shamefully.
2019-11-24 12:04:21 +01:00
Valentin Lorentz
a8b6698849 Add config supybot.reply.format.list.maximumItems to limit the size of format('%L', ...). 2019-11-23 18:48:58 +01:00
James Lu
9291fbd4a0 All plugins: set Limnoria contributors as maintainer 2019-11-16 11:41:13 -08:00
James Lu
a4701b258c Plugin: accept author name in 'contributors' command 2019-11-16 11:41:13 -08:00
James Lu
7854db7135 Better formatting in supybot.Author if some fields are missing 2019-11-16 11:41:13 -08:00
Valentin Lorentz
2dddfefa98 Fix log on SASL failure.
Broken by 04b55805b8.
2019-11-09 18:38:40 +01:00
Valentin Lorentz
6a9462be00 Fix reset of capabilities_ls.
Broken by 0014b206ad.
2019-11-09 18:27:07 +01:00
Valentin Lorentz
5e2343f717 Update doc of capabilities.default to mention 'channel capability setdefault'. 2019-11-08 20:53:04 +01:00
Valentin Lorentz
04b55805b8 Log SASL mechanism on failure. Closes GH-1014. 2019-11-02 20:52:58 +01:00
Valentin Lorentz
10ccfbbf3c Remove early return in upkeep() in case sys.stdout is replaced.
We don't want flushing to be entirely skipped just because
of that.
2019-11-01 22:18:32 +01:00
Valentin Lorentz
9268356e97 Split 'CAP REQ' commands to not exceed 512 bytes. 2019-10-25 23:07:31 +02:00
Valentin Lorentz
0014b206ad Reset capability set state on reconnection. 2019-10-25 22:40:51 +02:00
Valentin Lorentz
cfbbed3da9 Truncate incoming lines to 512-2, not 500. 2019-10-25 22:31:09 +02:00
Valentin Lorentz
71cc414ff3 Fix conditional on CTCP in urlSnarfer.
Broken in 8bb31a54e7.

( 8bb31a54e7\#diff-44309956f4d4fbbe0b8499c3d849080fL209-R212 )
2019-10-22 17:57:46 +02:00
James Lu
35a64eca38 Plugin: update tests
I'm taking the liberty of adding myself to supybot.authors here.
2019-10-19 11:34:24 -07:00
James Lu
930da6a6ba Use a real invalid email in supybot.authors.unknown 2019-10-19 10:20:38 -07:00
James Lu
e7f033539b Don't repeat nick in supybot.Author if nick and name are the same
This is the case e.g. for quantumlemur's plugins.
2019-10-19 10:20:38 -07:00
James Lu
18f9a342b3 Throw out mungeEmail for supybot.Author
This has limited value these days, because 1) the email info for authors is most often in a public VCS already 2) it makes using the actual contact info harder.
2019-10-19 10:20:35 -07:00
James Lu
b54d8f8073
regexp_wrapper: return None instead of False when search times out (#1379)
This allows plugins to detect whether a search timed out or did not match, which are two distinct outcomes.
2019-10-17 12:30:07 -07:00
Johannes Löthberg
27e7d6a9ac Aka: Add web UI (#1373)
* utils.web: Import html escaping functions

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* Aka: Add web interface for browsing Akas

Fixes #1226.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* httpserver: Actually handle KeyError in unhook

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* test: FakeHTTPConnection: Don't decode data in send

BaseHTTPRequestHandler expects to get bytes, so we can't decode the sent
data.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* test: HTTPPluginTestCase: Use BytesIO instead of StringIO

BaseHTTPRequestHandler expects bytes, not strings.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* test: HTTPPluginTestCase: Rewind wfile to 0 before reading the response

Otherwise the read pointer is at the end of the file.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* Aka: Add basic web UI tests

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2019-10-10 17:27:34 +02:00
Valentin Lorentz
8b2cbbc583 Use a monotonic time for registry cache.
So an old cache does not take precedence over a newly set value.
I noticed this bug because of the time going backward in tests
because of the time.time mock introduced in
dcf55cf6de, but this may happen
in production systems too.

Also adds another deprecation warning for python < 3.3.
2019-10-05 22:29:11 +02:00
Valentin Lorentz
a4665803fa News + RSS: Mock time.time() instead of using time.sleep() in tests.
Saves 40s over the ~5min test suite.
2019-10-05 12:22:30 +02:00
Valentin Lorentz
3c42ce0861 Only clear users db if the filename is set. 2019-09-28 10:33:54 +02:00
Valentin Lorentz
bcbaa979d5 Revert "Deduplicate (de)serialization code shared by UsersDictionary and ChannelsDictionary."
This reverts commit a4f8e3f647.
2019-09-28 10:33:10 +02:00
Valentin Lorentz
5bfee2e72b Fix typo in doc. 2019-09-26 23:00:01 +02:00