Commit Graph

1588 Commits

Author SHA1 Message Date
Valentin Lorentz
86b1741fdd Fix nondeterministic test on Python < 3.7. 2021-05-27 22:36:27 +02:00
Valentin Lorentz
e0fdcb67c0 Store IrcUser hostmasks in HostmaskSet to prevent their pattern cache from expiring
When the number of hostmasks exceeds 1000 (the hardcoded size of
_patternCache and _hostmaskPatternEqualCache), this triggers
a pathological case in the LRU caches, that causes all calls to be
a cache miss.
This means that on every IRC message received, ircdb.checkIgnored triggers
a recompilation of *all* user hostmasks, which is very expensive
computationally.

This commit stores them in their own cache to prevent them from
expiring.
2021-05-27 22:15:52 +02:00
Valentin Lorentz
d452a7051c callbacks: Don't write nick prefixes in the middle of multiline messages. 2021-04-01 20:10:17 +02:00
Valentin Lorentz
bbc2e9de0d irclib: 'lift' message tags to the batch when sending a multiline batch 2021-04-01 20:10:17 +02:00
Valentin Lorentz
bf90a7c94d callbacks: Make reply() send multiline batches when supybot.reply.mores.instant > 1 2021-04-01 20:10:17 +02:00
Valentin Lorentz
567618392f Add tests + fix bugs 2021-04-01 20:10:17 +02:00
Valentin Lorentz
d60cc5c92a irclib: add method getClientTagDenied
To allow plugins to check if they should send a tag or not.
2021-03-18 19:56:30 +01:00
Valentin Lorentz
cb7a395444 irclib: truncate outgoing messages to 512 bytes, not 512 chars 2021-03-11 19:02:55 +01:00
Valentin Lorentz
11e79e44c5 Remove the '(XX more messages)' when the next message is sent immediately after
It's pointless and looks stupid.

It will look even more stupid when we enable multiline, because the
suffixes will be in the middle of the concatenated message.
2021-03-05 21:19:02 +01:00
Valentin Lorentz
f98542e884 Add testReplyInstant
I'm going to mess with instant replies to add support for multiline,
so it's good to have a safety net.
2021-03-05 21:11:43 +01:00
Valentin Lorentz
6f6dad8f7b Add proper support for nested batches. 2021-03-03 23:32:00 +01:00
Valentin Lorentz
9719bb799e irclib: Send the bot user mode when advertized by the server
It is enabld by default in order to be a good netizen,
but can be overridden by admins if needed.

References:
*
* https://github.com/ircv3/ircv3-specifications/pull/439
2021-02-28 11:11:29 +01:00
Valentin Lorentz
772ec8d6a9 When getting STS policy over insecure connection, reuse the exact same IP address
Otherwise, if some IP addresses don't work (eg. all odd ones), the bot will
consecutively fail because it can't connect, then connect + get STS + reconnect,
then fail again, then connect + get STS, etc.
2021-01-11 23:22:21 +01:00
Valentin Lorentz
5d80b2eec9 irclib: Fix crash when MOTD is sent again later in the connection.
This can happen with this ZNC module: https://wiki.znc.in/Missingmotd
or if a plugin sends a 'MOTD' command.
2020-09-19 17:08:52 +02:00
Valentin Lorentz
0a6bb49fe6 irclib: Fix crash on CAP NEW.
Turns out, it wasn't tested so it never worked...
2020-09-19 16:55:51 +02:00
Valentin Lorentz
f4d6bd11be registry: forbid direct access to Regexp.setValue.
This is not a regression; this was already forbidden before
23417b0675, and this commit was not
tagged/released yet at the moment I'm writing this one.
2020-09-15 09:59:08 +02:00
Valentin Lorentz
ac94c5291e registry: fix Regexp initialization when the default value is not None. 2020-09-15 09:57:15 +02:00
Valentin Lorentz
23417b0675 registry: Fix regression preventing default None value for Regexp. 2020-09-05 22:20:38 +02:00
Valentin Lorentz
0284ed9ebd irclib: Don't error when 004 is missing umodes and chanmodes. 2020-07-05 19:45:08 +02:00
Valentin Lorentz
568b84847b irclib: Fix hang in cap nego when echo-message is available but not labeled-response.
echo-message ended up in self.state.capabilities_req even though it wasn't
requested, so the bot was stuck in state:
"Waiting for ACK/NAK of capabilities: {'echo-message'}".
2020-05-18 20:50:14 +02:00
Valentin Lorentz
759fca5eba Switch names of TimeoutDict and ExpiringDict.
For consistency, as TimeoutQueue has guaranteed deletion after the timeout,
like the new TimeoutDict (ex-ExpiringDict).
2020-05-10 08:42:25 +02:00
Valentin Lorentz
d205a9b5f8 Fediverse: Use ExpiringDict instead of TimeoutDict for the cache, it guarantees expiry after the timeout. 2020-05-10 08:34:36 +02:00
Valentin Lorentz
43a8724d3a Don't strip spaces when parsing registry values.
It breaks plugins.Messageparser.listSeparator, and probably others.
2020-05-08 22:18:27 +02:00
Valentin Lorentz
0d89b2352b Add plugin load case-insensitivity test. 2020-05-08 11:58:12 +02:00
Valentin Lorentz
83a8afde16 Add experimental support for +draft/reply client capability on outgoing messages. 2020-05-07 21:17:55 +02:00
Valentin Lorentz
eb1e27e20b Add echo messages, either with the echo-message capability or simulated.
Plugin can opt in to getting echo messages by setting the class attribute
'echo_message = True' if they want to get echos.
This defaults to False in order not to break existing plugins, and because
they usually don't need it (there's outFilter for most cases).
2020-05-07 21:08:07 +02:00
Valentin Lorentz
2008f7b815 Exclude server_tags from truncation.
They have their own 8191 bytes.
2020-05-07 18:38:17 +02:00
Valentin Lorentz
da328b4985 Expire batches that never ended to avoid leaking memory. 2020-05-06 20:39:21 +02:00
Valentin Lorentz
cc0af4e790 Include start and end messages in a batch.
They may have useful server tags (especially when we start
supporting labeled-response).
2020-05-06 18:29:17 +02:00
Valentin Lorentz
fc4cc956ba Merge branch 'sts' into testing 2020-05-02 17:10:13 +02:00
Valentin Lorentz
8d377e4416 Fix non-deterministic test on python <= 3.6 2020-05-02 00:06:55 +02:00
Valentin Lorentz
01dcbf412b Fix edge case of server tags unescaping, when the backslash is followed by an 'invalid' char. 2020-05-01 23:46:34 +02:00
Valentin Lorentz
e92156711b Only spaces are token separators, not all whitespaces. 2020-05-01 23:44:38 +02:00
Valentin Lorentz
f4d5b866d9 tests: raw strings for better readability. 2020-05-01 23:37:59 +02:00
Valentin Lorentz
1854d86476 Add support for outputting server tags.
Will be useful when we start sending client tags.
2020-05-01 23:35:52 +02:00
Valentin Lorentz
22120ee862 Fix various issues with STS handling. 2020-05-01 19:46:19 +02:00
Valentin Lorentz
51ff013fcc Apply STS policies when connecting to a server. 2020-05-01 19:46:19 +02:00
Valentin Lorentz
ecc2c32950 Add support for storing STS policies.
If on an insecure connection: reconnect.
If on a secure connect: store it and do nothing else.

For now, stored STS policies are not read when connecting to an
insecure server.
2020-05-01 19:46:19 +02:00
Valentin Lorentz
45ff70907f [WIP] Start reworking Irc around a FSM.
To keep track of connection state instead of a complex implicit flow
between handling functions.
2020-05-01 19:43:27 +02:00
Valentin Lorentz
0b0da9716d callbacks: honor network-specificity of supybot.reply.whenAddressedBy.
A side-effect is that plugins should now pass 'irc' instead of 'irc.nick'
when they call 'callbacks.addressed()'.
2020-04-11 15:00:46 +02: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
e7553dcca4 Add subcommand dispatching for CAP/FAIL/WARN/NOTE. 2020-01-23 14:25:10 +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
fcb342cb2c test: Mock calls to time.sleep()
The tests now take 7 seconds instead of 30.
2019-12-15 20:20:42 +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
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
b2f6c3c83f test: Don't overwrite the main Schedule in the driver list.
Closes GH-1385.
2019-11-11 18:06:07 +01:00
Valentin Lorentz
9268356e97 Split 'CAP REQ' commands to not exceed 512 bytes. 2019-10-25 23:07:31 +02:00
Valentin Lorentz
573921c00f Merge branch 'netconf-and-ircmsgs-channel' into testing 2019-09-14 12:10:47 +02:00