Commit Graph

3957 Commits

Author SHA1 Message Date
Valentin Lorentz
41c5589bea utils.str: Rely only on the documented methods of textwrap.TextWrapper.
'_split_chunks()' should be fine, but '_wrap_chunks()' is the only one explicitly
documented as overridable, so it's probably safer to use.
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
92399bb6a7 drivers: Don't strip all whitespaces before parsing messages.
They matter in multiline messages, and there isn't much point to
stripping them anyway.
2021-04-01 20:10:17 +02:00
Valentin Lorentz
7cb3ae12da Misc: Make @more reply in batches when possible. 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
d5d22985f5 irclib: Remove special-casing of the last instant message in _sendReply
There is no reason for it to be special; and this special-casing would be
annoying when we add support for outgoing multiline batches.
2021-04-01 20:10:17 +02:00
Valentin Lorentz
de29218bdb irclib: Make NestedCommandsIrcProxy._replyOverhead count in bytes instead of chars
It was, once again, a bug to count characters, because they
might contain multi-byte characters, and truncation happens
after the 512th byte.
2021-04-01 20:10:17 +02:00
Valentin Lorentz
8a3efe4379 irclib: Split _sendReply from NestedCommandsIrcProxy.reply
This function was getting uncomfortably big.
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
99a6a7cde9 raise exceptions instead of logging, so we get a helpful traceback 2021-04-01 20:10:16 +02:00
Valentin Lorentz
c7939d3eb5 [wip] typo 2021-04-01 20:10:16 +02:00
Valentin Lorentz
26f2d9a292 [wip] idea for ordering batches in Irc.queue 2021-04-01 20:10:16 +02:00
Valentin Lorentz
e19436a4ba [wip] support outgoing batches 2021-04-01 20:10:16 +02:00
Valentin Lorentz
8b90884fa0 irclib: Copy messages before echoing them
Fixes a bug triggered by Relay when it relays between three or more networks.
2021-04-01 20:09:28 +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
0919b9f58a ircmsgs: Fix function docstrings. 2021-03-11 19:46:05 +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
9bfa1458ef httpserver: improve error handling when binding ports
1. better error messages
2. try binding other ports even if one fails
2021-03-09 23:14:23 +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
4aca6e3d5a Add support for receiving commands from draft/multiline batches. 2021-03-04 21:34:25 +01:00
Valentin Lorentz
f8c5221efd do43x: add the current nick to the list of tried nicks.
The original nick was never added to the list...
2021-03-04 21:29:23 +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
e54751f9c9 Make the email regexp less strict.
The former one disallowed too many valid address, eg. those containing
quotes or square brackets.
2021-01-25 19:49:08 +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
ba77de0946 Try all IP addresses of a hostname.
Fixes a regression in ecc2c32950 that caused
Socket.py to ignore the IP address entirely after computing it, and
to call getSocket() and connect() with the hostname instead.
2020-12-05 14:26:52 +01:00
Valentin Lorentz
771c05c666 irclib: Fix test failure
FAIL: testMoreIsCaseInsensitive (Misc.test.MiscTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/test.py, line 214, in runTest
    originalRunTest()
  File ./plugins/Misc/test.py, line 260, in testMoreIsCaseInsensitive
    self.assertNotError('more %s' % nick.upper())
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/test.py, line 355, in assertNotError
    m = self._feedMsg(query, **kwargs)
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/test.py, line 526, in _feedMsg
    response = self.irc.takeMsg()
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/log.py, line 368, in m
    return f(self, *args, **kwargs)
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/irclib.py, line 1308, in takeMsg
    assert not msg.tagged('emulatedEcho')
AssertionError

I don't understand why it's happening or why it's only that specific test,
but there we go.
2020-11-10 09:47:36 +01:00
Valentin Lorentz
c062787436 irclib: use a dedicated tag to detect emulated echo-messages, instead of receivedAt.
Plugins implementing inFilter do not set receivedAt, so incoming messages
rewritten by inFilter would be detected as echo messages, and ignored
by most plugins.
2020-11-04 11:32:20 +01:00
Valentin Lorentz
903eceebda Simplify checkIgnored code from previous commit 2020-11-04 11:32:20 +01:00
Valentin Lorentz
76b5a42428 supybot.defaultIgnore shouldn't ignore registered users.
Even if they are not trusted. This fixes a regression in
97016b9c55.

This happens because 'user._checkCapability' raises a KeyError
when the user has neither this cap or the anticap; which was mistakenly
caught here by the 'except KeyError' expecting to catch non-existing
users.
(And that why 'try' blocks should be limited to as few lines as possible.)
2020-10-26 00:19:57 +01:00
Valentin Lorentz
160bcc8b6b Revert "irclib: Fill the nick and prefix of simulated echo messages."
This reverts commit 1fe414764c.

I initially wrote that commit so that plugins with echoMessage=True can
get the nick/prefix from the message (eg. the SkypeRelay plugin in my
personal repo).
Unfortunately, this breaks any test that does equality comparison on
between the result of getMsg()/takeMsg() and an IrcMsg object they
crafted themselves.

Additionally, the filled in nick and prefix might be inaccurate if the
bot changes nick/host at the same time. So instead plugins should check
for the None value.

(Also, editing IrcMsgs on the fly like this isn't great, and the commit
forgot to reset the `_str` attribute.)
2020-10-22 20:04:23 +02:00
Valentin Lorentz
1fe414764c irclib: Fill the nick and prefix of simulated echo messages. 2020-10-17 14:22:48 +02:00
Valentin Lorentz
4213d95356 plugin setup: declare the long_description is in markdown
Else PyPI rejects it because it can't parse it as ReST.
2020-10-07 19:46:56 +02:00
Valentin Lorentz
48b24769c2 irclib: Document classes better, especially instance attributes. 2020-09-27 15:51:01 +02: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
6a3be33fcd registry: Don't use an internal state for Regexp, it breaks net- and chan- specific values. 2020-09-05 21:40:40 +02:00
Valentin Lorentz
97016b9c55 Exempt trusted users from being ignored.
Closes GH-66.
2020-09-05 16:42:28 +02:00
Valentin Lorentz
a55fbab591 Autocomplete: Initial implementation.
This plugin implements the first version of
https://github.com/ircv3/ircv3-specifications/pull/415
2020-08-29 16:33:29 +02:00
Valentin Lorentz
fe84bfbbb6 callbacks: add comments to findCallbacksForArgs. 2020-08-29 16:29:40 +02:00
Valentin Lorentz
5dc72d2b34 Rename IrcCallback.echo_message to IrcCallback.echoMessage.
For consistency with 'alwaysCall' and 'noIgnore'.
2020-08-23 16:27:22 +02:00
Valentin Lorentz
761fc2353e utils.net: Do not disable TLS certificate check when authorityCertificate is set.
It makes sense that manually configuring a CA overrides this
value which defaults to False.
2020-08-01 21:46:26 +02:00
Valentin Lorentz
57da6d04e2 utils.net: always check fingerprints if they are set, even if verifyCertificates is False.
It makes sense that manually configuring fingerprints overrides this
value which defaults to False.
2020-08-01 21:45:08 +02:00
Valentin Lorentz
8f72c418e5 callbacks: don't crash when the prefix is from network services. 2020-07-25 15:29:23 +02:00
Gordon Shumway
5315cd3275 userAgents: avoid potential IndexError
random.choice() should only be run after verifying the config has been set.
2020-07-12 16:42:42 +02:00
Gordon Shumway
4c4d0024ca
Fix typo. HttpUserAgent -> HttpUserAgents (#1424)
Fixes typo in https://github.com/ProgVal/Limnoria/pull/1423
2020-07-11 15:13:13 -07:00
Gordon Shumway
73de5616e8
Selectable User-Agent for HTTP requests (#1423)
https://github.com/ProgVal/Limnoria/issues/1382
2020-07-11 10:25:09 +02:00