Commit graph

1019 commits

Author SHA1 Message Date
jesopo
dce6eee8c9 move _raise_deadline() out of except block to clean up printed stacktrace 2019-09-18 10:21:40 +01:00
jesopo
ee6360be22 don't check already-read data when checking for too-large requests
this check was here because the first read will return empty if it was an
invalid byte sequence for e.g. gzip because we needed to receive more data. the
second read will always return data (not decoded) so regardless of what the
already-read data is, the second read is the only criteria we need.
2019-09-17 17:33:23 +01:00
jesopo
1ac7f2697e log which URL caused an error in request_many 2019-09-17 17:09:19 +01:00
jesopo
98545a9fb4 only decode content-types in DECODE_CONTENT_TYPES 2019-09-17 16:12:03 +01:00
jesopo
8ca0d30fef Response.__init__() needs encoding now 2019-09-17 14:11:12 +01:00
jesopo
b7dd78ef1a restore 5 second (instead of default 10) deadline for http.request 2019-09-17 13:44:14 +01:00
jesopo
94c3ff962b use utils.deadline_process() in utils.http._request() so background threads can
call _request()
2019-09-17 13:41:11 +01:00
jesopo
fa95eaa9eb add .get() to CaseInsensitiveDict 2019-09-17 13:40:37 +01:00
jesopo
d454f9b732 use Queue.get() with timeout, not Process.join() for timeout
this was because the threads spawned by multiprocessing.Queue seemed to be
making Process.join() believe the subprocess had not exited.
2019-09-17 13:39:23 +01:00
jesopo
1ed14f9a17 first draft of multiprocess.Process deadline system 2019-09-17 11:56:30 +01:00
jesopo
c23530be89 add missing IRCLine import to IRCChannel 2019-09-17 10:21:31 +01:00
jesopo
334d580c57 'seperate_hostmask()' -> 'parse_hostmask()' 2019-09-16 18:43:57 +01:00
jesopo
03892d0ae3 topic_setter should be stored as a Hostmask 2019-09-16 18:38:46 +01:00
jesopo
a48aececfd EventRoot._hook's kwarg should be a list of tuples 2019-09-16 15:34:34 +01:00
jesopo
47735421b8 add json_body arg to Request to json-encode body, only return from body if
not null
2019-09-16 10:57:18 +01:00
jesopo
f9d13dc373 support '0' as an IntSetting value 2019-09-15 22:22:30 +01:00
jesopo
60ced118a0 get_user_status() -> get_user_modes(), filter in format_activity.py 2019-09-12 22:39:21 +01:00
jesopo
d950eb3660 add utils.SensitiveSetting, to .format() hide value 2019-09-12 12:17:31 +01:00
jesopo
ba0911f2e7 add utils.Setting.format() so subtypes can format differently 2019-09-12 12:17:09 +01:00
jesopo
9d33354d16 translate INVITE from [channel_name, target] to [target, channel_name] 2019-09-12 11:24:25 +01:00
jesopo
540c7b8c44 Revert "INVITE should be [channel_name, target]"
This reverts commit f3d8ffad2c.
2019-09-12 11:23:29 +01:00
jesopo
f3d8ffad2c INVITE should be [channel_name, target] 2019-09-12 11:21:29 +01:00
jesopo
77f50187c5 allow Requests to specify a useragent 2019-09-12 10:41:50 +01:00
jesopo
2c5a2d9db3 add IRCChannel.send_invite() 2019-09-12 10:24:02 +01:00
jesopo
2bd7d591c3 Revert "add IRCBot.http_client(), to allow modules to override default http client"
This reverts commit 81347fbba0.
2019-09-11 18:08:44 +01:00
jesopo
81347fbba0 add IRCBot.http_client(), to allow modules to override default http client 2019-09-11 17:54:24 +01:00
jesopo
9d6a3982ed add a helper utils.http.Client static object 2019-09-11 17:53:49 +01:00
jesopo
51dc26d113 add proxy to Request objects 2019-09-11 17:53:37 +01:00
jesopo
4a97c9eb0d refactor utils.http.requests to support a Request object 2019-09-11 17:44:07 +01:00
jesopo
8f8cf92ae2 automatically decode certain http content types 2019-09-11 15:28:13 +01:00
jesopo
8d8d9219b8 don't return "+" when a channel has no modes 2019-09-10 15:10:14 +01:00
jesopo
a9b106c6be Don't try to .decode non-html things, default iso-lat-1 for non-html too 2019-09-09 16:17:26 +01:00
jesopo
b83f5d9e30 add flag to disable encoding detection 2019-09-09 14:59:08 +01:00
jesopo
5ef2b7af27 'str.split' -> 's.split' 2019-09-09 14:53:11 +01:00
jesopo
1df82c1cb2 still default to iso-latin-1 if no on-page or in-header content-type is present 2019-09-09 14:48:26 +01:00
jesopo
0a67659637 only look for <meta>-related tags when there are meta tags 2019-09-09 14:39:19 +01:00
jesopo
0a1077c5cd add explicit None return for _find_encoding (mypy) 2019-09-09 14:25:01 +01:00
jesopo
ff9c82bf67 change utils.http.request to best-effort detect on-page encoding
closes #113
2019-09-09 14:11:18 +01:00
jesopo
dadefeb8f3 remove try-rejoin (on 477) logic. will move to a module later 2019-09-07 15:21:35 +01:00
jesopo
d973b547e1 add a create flag to IRCChannels.get_id() to optionally not create new ids 2019-09-05 14:13:58 +01:00
jesopo
d7ae182428 cache when a setting isn't set but don't cache "default" value 2019-09-04 15:26:36 +01:00
jesopo
473c2723e7 only cache get_setting value when it's not the default value 2019-09-04 15:24:50 +01:00
jesopo
007bb78d30 make utils.from_pretty_time() format much stricter 2019-09-04 11:22:56 +01:00
jesopo
397cfa8e7e correctly qualify DeadlineExceededException namespace 2019-09-03 14:54:59 +01:00
jesopo
b7b2f31c1c use utils.deadline() in utils.http.request, not raw sigalrm 2019-09-02 15:50:21 +01:00
jesopo
d42d694e64 move deadline alarm time check inside try/finally 2019-09-02 15:50:12 +01:00
jesopo
a160148c2f actually prune non-loadable modules before doing dependency checks 2019-09-02 15:46:31 +01:00
jesopo
43a7b7d949 add basic caching logic for channel settings 2019-09-02 14:07:39 +01:00
jesopo
7959f1ab88 change Cache.py to be key:value 2019-09-02 14:07:26 +01:00
jesopo
9cc1ee98eb Pass the content of a webpage to HTTPParsingException 2019-09-02 13:27:44 +01:00
jesopo
408b89aeb7 use \S+ for url regex (for non-ascii chars), use url_sanitize to catch <> 2019-09-02 13:25:48 +01:00
jesopo
9e43ea1599 add per-user fediverse setting 2019-09-02 08:51:56 +01:00
jesopo
19d8f0b497 store and expose reconnection timers on IRCBot.reconnections 2019-09-01 08:38:22 +01:00
jesopo
6a068777d6 v1.11.1 release 2019-08-30 19:10:17 +01:00
jesopo
722d6418c8 switch to using signal.setitimer so we can restore previous timer 2019-08-30 18:36:48 +01:00
jesopo
a57a06b1cc switch utils.deadline to a context manager 2019-08-30 18:13:12 +01:00
jesopo
e97e3c8f30 add utils.deadline(func, seconds) to put hard limits on code exec time 2019-08-30 17:17:03 +01:00
jesopo
4bfb4c3200 Add IntRangeSetting, reorder OptionsSetting arg order 2019-08-30 14:40:54 +01:00
jesopo
2c812ccaaa Logging.BitBotFormatter no longer uses the format it's given (always iso8601) 2019-08-30 13:46:21 +01:00
jesopo
58a4fd7e74 round microseconds up to a whole number and zero-pad to 3 chars 2019-08-30 13:46:00 +01:00
jesopo
d3ed08e336 Don't use 'Z' for "utc timezone" - actually parse timezone out of datetimes 2019-08-30 13:25:19 +01:00
jesopo
b037c3076f v1.11.0 release 2019-08-15 13:45:54 +01:00
jesopo
61eeba0cb9 should only return a BufferLineMatch when we actually match 2019-08-15 13:45:04 +01:00
jesopo
195cb66e26 Update CHANGELOG.md, bump version to v1.11.0-rc3 2019-08-14 15:17:01 +01:00
jesopo
814236915b forgot to update IRCBot.VERSION to v1.11.0-rc2 2019-08-13 15:11:43 +01:00
jesopo
03c7e8f066 return matching string from buffer.find() as most uses were redundantly regexing 2019-08-13 13:48:03 +01:00
jesopo
0f4a4d04a1 v1.11.0-rc1 release 2019-08-09 15:02:10 +01:00
jesopo
b6361ba4e3 Remove extraneous space 2019-08-07 14:00:56 +01:00
jesopo
20042edfd9 Allow bypass of content-type check in utils.http.request 2019-08-05 15:41:02 +01:00
jesopo
d093027431 not all HTTP responses have content-type 2019-08-02 17:33:16 +01:00
jesopo
dd8b276b35 pull priority out of kwargs in _hook 2019-07-30 15:24:13 +01:00
jesopo
27a6078f20 Revert "hook priority position should default to 0, not end"
This reverts commit ff0cc59507.
2019-07-30 15:23:13 +01:00
jesopo
5ffe2941e8 Revert "we should be checking if the new hook has a higher priority"
This reverts commit b145e664e1.
2019-07-30 15:23:05 +01:00
jesopo
b145e664e1 we should be checking if the new hook has a higher priority 2019-07-30 15:12:29 +01:00
jesopo
ff0cc59507 hook priority position should default to 0, not end 2019-07-30 15:09:34 +01:00
jesopo
793fc94ea3 source should have ':' appended 2019-07-28 20:55:54 +01:00
jesopo
ad8f66c00e Remove debug print 2019-07-28 18:14:44 +01:00
jesopo
163e979f95 move socket creation to it's own function, send event just prior to .connect 2019-07-28 18:07:23 +01:00
jesopo
9827feeabd 'name' -> 'key' (copypaste fail) 2019-07-28 18:07:01 +01:00
jesopo
25b507e80c Refactor hook kwargs to be stored as a list of tuples to support key duplicates
closes #108
2019-07-28 12:35:04 +01:00
jesopo
77dfc76591 switch to function/module magic being a single object 2019-07-26 11:58:06 +01:00
jesopo
b6844303cb add set_throttle(lines, seconds) function to tweak throttle per-server 2019-07-23 17:46:22 +01:00
jesopo
4babce5357 Only fill throttle when buffer is empty 2019-07-22 13:14:07 +01:00
jesopo
304fcdaebb gotta str()-ify kwargs before logging it 2019-07-15 14:27:55 +01:00
jesopo
4815c1612c don't silently truncate at newline in IRCLine.ParsedLine.truncate() 2019-07-15 14:26:45 +01:00
Mikaela Suomalainen
2f18414cb7
src/EventManager.py: fix typo defualt -> default 2019-07-13 13:04:37 +03:00
jesopo
89c12e845a add --remove-server/-R cli arg 2019-07-12 09:30:22 +01:00
jesopo
ab45c65fb4 'self.channels' -> 'self._channels' 2019-07-11 14:22:33 +01:00
jesopo
02838e4802 Return new Timers 2019-07-09 11:16:34 +01:00
jesopo
32fa999c78 Allow Timer objects to be cancelled 2019-07-09 11:14:05 +01:00
jesopo
c19c6c0e14 asyncio.gather -> asyncio.wait (with timeout) 2019-07-08 14:50:11 +01:00
jesopo
469c725675 tell asyncio.gather which loop to use 2019-07-08 14:41:12 +01:00
jesopo
a1438abf66 close event loop when we're done with it (request_many()) 2019-07-08 13:59:48 +01:00
jesopo
81c7af8ab5 Don't try/except async http exceptions 2019-07-08 13:51:02 +01:00
jesopo
ee0ec0eca1 switch request_many() to use asyncio.gather 2019-07-08 13:46:27 +01:00
jesopo
b62ba469d7 catch async exceptions in utils.http.request_many() 2019-07-08 13:18:59 +01:00
jesopo
078681eddf add missing schema in utils.http.sanitise_url, use in rss.py 2019-07-08 12:54:06 +01:00
jesopo
ecb8364d0d switch to using asyncio's event loop 2019-07-08 12:45:10 +01:00
jesopo
15e143fcff implement utils.http.request_many as a tonado ioloop yield 2019-07-08 11:43:09 +01:00
jesopo
f9d5271762 "paramatered" -> "parametered" 2019-07-04 17:23:36 +01:00
jesopo
43c8ad0ff6 Add !editserver command 2019-07-04 13:15:51 +01:00
jesopo
3afbe5fd82 threading.Lock() around any access to _write_buffer 2019-07-04 06:56:05 +01:00
jesopo
76ab7935a0 return parsed modes from IRCChannel.parse_modes, pass through mode events 2019-07-03 08:13:28 +01:00
jesopo
637067c62c url_validate() -> url_sanitise() 2019-07-02 14:15:49 +01:00
jesopo
534854127b Add utils.http.url_validate() for best-effort url tidying 2019-07-02 14:10:18 +01:00
jan6
b6e9713a14 fixed capabilities 2019-07-01 14:41:47 +03:00
jesopo
19f716ab4c Implemnt _options_factory for OptionsSetting to have dynamic options 2019-06-29 22:26:28 +01:00
jesopo
b4c762eb4e Automatically format example text for OptionsSetting (showing options) 2019-06-29 21:33:26 +01:00
jesopo
7091860e54 Setting.__init__ call in OptionsSetting ctor needs self param 2019-06-28 23:27:56 +01:00
jesopo
756396d758 Implement utils.OptionsSetting 2019-06-28 23:26:42 +01:00
jesopo
ae9d099a41 Refactor set/channelset/serverset/botset in to 'utils.Setting' objects 2019-06-28 23:16:05 +01:00
jesopo
f9eb017466 message arg for HTTPWrongContentTypeException/HTTPParsingException 2019-06-28 23:01:21 +01:00
jesopo
97810db8df Give descriptions to utils.http.HTTPException subclasses 2019-06-27 18:28:08 +01:00
jesopo
3c3f0449b6 add CaseInsensitiveDict.__contains__ 2019-06-26 17:57:49 +01:00
jesopo
16d331dd43 add allow_redirects kwarg to utils.http.request() 2019-06-26 17:53:16 +01:00
jesopo
c5785a2d14 implement @utils.kwarg() magic, use it for command.regex hooks 2019-06-26 14:37:41 +01:00
jesopo
7060a0ac67 Update IRCBot except queue.Empty comment 2019-06-26 13:43:00 +01:00
jesopo
4bf5c4783b Re-add EventManager check to prevent _call() outside main thread 2019-06-26 11:42:23 +01:00
jesopo
bb749b111f Refactor EventManager to only hold hooks on a root object 2019-06-26 11:01:09 +01:00
jesopo
12181bfec6 Add system to have multiple url shorteners and chose which to use 2019-06-25 17:53:00 +01:00
jesopo
a1cc2e778c Return 0 seconds if timeout seconds is negative 2019-06-24 17:22:08 +01:00
jesopo
ef0b3ec64c move _check() after timeouted queue.get() so deadlines are met accurately 2019-06-23 20:50:40 +01:00
jesopo
dd1df4dc05 move get_poll_timeout() to event loop now that it is the one calling _check 2019-06-23 19:00:37 +01:00
jesopo
9673963a8d shift _check() call to event loop function so read_loop needn't call trigger() 2019-06-23 18:53:25 +01:00
jesopo
102aa1dce1 v1.10.0 release 2019-06-23 14:45:56 +01:00
jesopo
afc287f020 Don't print BitBotPanic stacks when we don't need to 2019-06-23 10:01:15 +01:00
jesopo
7861210495 v1.10.0-rc2 2019-06-23 09:45:47 +01:00
jesopo
22574448da until_read_timeout is a func - read_timed_out has always been returning false 2019-06-22 23:31:06 +01:00
jesopo
01bad3a76e Don't needlessly call time.monotonic() when checking cache expirations 2019-06-22 23:30:15 +01:00
jesopo
7d49826b1a v1.10.0-rc1 2019-06-22 22:41:17 +01:00
jesopo
f1abc5f10c remove remove_own_mode( check - deferred_read.py better solves the issue.
the issue was getting a MODE line on irc.com prior to 001, thus we didn't know
what our nickname was thus we didn't know that the MODE was for us. not dying
when we saw +x was easy to do with this check but I think it's more correct to
actually parse that MODE after 001 so we know we have +x.
2019-06-22 22:23:05 +01:00
jesopo
3eac36d0f5 Restrict EventManager calls to the main thread 2019-06-22 12:21:44 +01:00
jesopo
a783e71ad4 return generated SentLine objects from IRCChannel.send_* functions 2019-06-21 18:25:21 +01:00
jesopo
90c90e5bbd Implement dependency system for CAPs 2019-06-21 18:05:11 +01:00
jesopo
8a0d99f969 Adda system of aliases for CAPs, mostly for changeable draft specs and creating
dependence between moving specs
2019-06-21 17:15:46 +01:00
jesopo
bffc5b0ec4 WARN log when we try to remove a mode from ourselves that we didn't have 2019-06-21 11:16:53 +01:00
jesopo
01438f28f6 check we have a mode before trying to remove it 2019-06-21 11:14:10 +01:00
jesopo
e7b17f2ccd give every ParsedLine a uuid4 .id for tracking purposes 2019-06-21 10:33:59 +01:00
jesopo
01ddc04bb9 fix hostmask_match_many type hinting 2019-06-20 17:58:49 +01:00
jesopo
b6e194a450 Implement hostmask_match_any, for more efficient matching of multiple hostmasks 2019-06-20 14:21:11 +01:00
jesopo
792a42be6e Implement utils.irc.hostmask_match() as regex 2019-06-20 14:10:10 +01:00
jesopo
612c26ff7e Differentiate between module "not found" and "not loaded" 2019-06-19 23:11:42 +01:00
jesopo
928f2f304d Raise ModuleNotFoundException on failure to find_module() 2019-06-19 23:05:22 +01:00
jesopo
dc9cd2869f Give requested module name to ModuleNotFoundException 2019-06-19 23:03:27 +01:00
jesopo
9457430c15 Add MessageTag.present, to see if a tag is present (even without value) 2019-06-19 22:36:42 +01:00
jesopo
938e1db963 add margin arg to ParsedLine.truncate so commands/outs.py doesn't do it
manually and cause potential issues with multi-byte chars
2019-06-19 10:34:42 +01:00
jesopo
c463fa20a4 line_formatted -> valid so tags don't cause us to subvert truncation 2019-06-18 18:14:04 +01:00
jesopo
1cbc2ce31b Tags should not be appended to pieces now that they're counted separately 2019-06-18 17:56:20 +01:00
jesopo
aa4a15a6dc Add IRCBot.URL (https://bitbot.dev) 2019-06-18 17:33:54 +01:00
jesopo
51cac7d9b5 add has_tag() and get_tag() to IRCLine.ParsedLine 2019-06-18 15:18:44 +01:00
jesopo
31be78db81 message-tags count for a different character limit than the rest of the line 2019-06-18 14:33:51 +01:00
jesopo
621830c360 Simplify SentLine by shifting truncation to ParsedLine (and commands.outs) 2019-06-18 14:14:37 +01:00
jesopo
133ff1c0f6 only count "\n"s (not "\r\n") that hit the wire, incase \r\n gets cut in half 2019-06-17 18:23:38 +01:00
jesopo
d4391cc6c5 Fix Database.ChannelSettings.find SQL 2019-06-17 17:51:27 +01:00
jesopo
5c325d9b23 'break' instead of 'continue' so that things in the event queue get discarded 2019-06-17 16:19:20 +01:00
jesopo
72ce880478 Only panic() when a server connection is part of bot init. closes #69 2019-06-17 14:20:11 +01:00
jesopo
9121a868a8 Make sure we exit event loop when there's no servers left 2019-06-17 14:07:06 +01:00
jesopo
dbe0b1f43b Tell servers objects when they are the result of a reconnection 2019-06-17 13:53:17 +01:00
jesopo
ec733e200c Default IRCBot.running to false, set to true at the top of .run() 2019-06-17 11:35:45 +01:00
jesopo
da5d48400d Change panic() reason log from ERROR to CRITICAL 2019-06-17 11:12:04 +01:00
jesopo
9ea356bc49 Raise a BitBotPanic() exception in panic() 2019-06-17 11:11:35 +01:00
jesopo
f8fa529ca5 Add IRCBot.panic() - a nicer interface for killing the whole application 2019-06-17 11:06:03 +01:00
jesopo
ced59a0f74 Allow channel-access and channel-mode check for channels people are not in 2019-06-16 20:48:31 +01:00
jesopo
18004c23e1 Don't fail get_kwarg when self.kwarg[name] is falsey 2019-06-16 18:39:56 +01:00
jesopo
5fa3d66a39 Return all caps through received.cap.ls|new and check if valid in line_handler,
remove server.cap_started
2019-06-16 15:33:20 +01:00
jesopo
919a488e86 Implement client-to-server BATCHes 2019-06-16 09:52:54 +01:00
jesopo
055eed24fd Type annotate ParsedLine.tags, add ParsedLine.add_tag() 2019-06-16 09:52:25 +01:00
jesopo
8ab4880c5c Change from yield checks to a func in events that pass up EventErrors 2019-06-15 18:42:14 +01:00
jesopo
b5a467552f CRITICAL log exceptions caught in _loop_catch() 2019-06-15 00:39:52 +01:00
jesopo
e0d99fe8b1 Fix utils.Check args type hinting 2019-06-14 12:12:38 +01:00
jesopo
f05fc209b0 Add a way to __or__ utils.Checks, as a "if one of these passes" thing 2019-06-14 12:01:55 +01:00
jesopo
d7fa2cfa24 Catch yields in command callbacks for e.g. permission checks 2019-06-14 11:42:12 +01:00
jesopo
0e5ba747a9 Wrap _read_loop() and _write_loop() in a try that kills the main thread 2019-06-13 17:11:46 +01:00
jesopo
795f6afbeb Mode mode (and mode arg) parsing to IRCChannel.py, add IRCChannel.mode_str 2019-06-13 11:53:47 +01:00
jesopo
8135f871c3 Change send_*() function return hints to be typing.Optional 2019-06-10 15:02:03 +01:00
jesopo
6c5dc958d0 Add .assure() to ParsedLine, to make it immune from .valid() 2019-06-10 10:45:02 +01:00
jesopo
0fc03fd592 Allow preprocess.send callbacks to request a line not be sent at all 2019-06-10 10:11:31 +01:00
jesopo
512d844a5a Update CHANGELOG, v1.9.2 release 2019-06-09 17:34:45 +01:00
jesopo
a31793c851 Put responsbility of self.running = False on to the event loop 2019-06-09 14:59:28 +01:00
jesopo
e28a8d91ab IRCServer.statusmsg type hint 2019-06-08 12:10:14 +01:00
jesopo
55fb9cee3b v1.9.1 release 2019-06-08 11:03:18 +01:00
jesopo
d4ba98307f We should look at ISUPPORT's STATUSMSG token instead of PREFIX 2019-06-08 10:59:52 +01:00
jesopo
16b9361371 Only request a CAP once. closes #66 2019-06-08 10:17:13 +01:00
jesopo
37c74da0f8 v1.9.0 release 2019-06-07 17:13:53 +01:00
jesopo
f822345976 Merge branch 'master' into feature/write-thread 2019-06-07 15:07:31 +01:00
jesopo
accd7a8941 Logging._log()'s params arg should be typing.Optiona[] 2019-06-07 13:35:20 +01:00
jesopo
ea924df883 typehint for IRCBuffer._lines 2019-06-07 13:34:30 +01:00
jesopo
bc4a6debb5 Use a deque for temp chathistory storage (src/IRCBuffer.py) 2019-06-07 13:31:51 +01:00
jesopo
38a41a6404 We need to wait for _check to finish so read/writes can be triggered correctly 2019-06-07 11:05:55 +01:00
jesopo
09fbbae5e3 "send" event on SentLines should be run on the main thread 2019-06-07 11:05:43 +01:00
jesopo
b3b4d07e63 Call _check *after* read epoll call - to make sure timeouts are hit accurately 2019-06-07 10:39:31 +01:00
jesopo
f3b6d6df0a Switch to using threading.Condition to trigger write thread 2019-06-07 10:39:19 +01:00
jesopo
1f1b63ea6d Checking if we should enable write buffer should be in _fill_throttle() 2019-06-07 08:02:22 +01:00
jesopo
c89bd74a48 select.poll, as opposed to select.epoll, uses milliseconds not seconds for
timeout
2019-06-06 23:45:33 +01:00
jesopo
23d2993b9f Remove debug print 2019-06-06 23:25:03 +01:00
jesopo
6d44f12193 Use .trigger (without triggering read/write threads) to call _check 2019-06-06 23:23:46 +01:00
jesopo
24ca7ed97f use trigger_write() instead of a raw .send(b"") 2019-06-06 23:19:57 +01:00
jesopo
ef0c2c65e0 use _event_queue for _check, don't .disconnect() from outside of respective
loops
2019-06-06 22:36:56 +01:00
jesopo
ae6c65d743 remove _trigger_function code, it's not used any more 2019-06-06 21:43:21 +01:00
jesopo
d9de4fdec2 Lambda scopes are irritating 2019-06-06 21:03:25 +01:00
jesopo
539bebafea select.epoll -> select.poll 2019-06-06 20:26:05 +01:00
jesopo
0f7b040165 call timer callbacks and expire cach objects on main thread 2019-06-06 20:22:56 +01:00
jesopo
5b7d8dea91 Only trigger read/write threads once 2019-06-06 19:21:18 +01:00
jesopo
05fcb33ff7 print lines as soon as they're read, don't wait for _post_send 2019-06-06 19:15:34 +01:00
jesopo
f96378ac07 move immediate-write-trigger to IRCServer.py, trigger _event_loop for
running=False
2019-06-06 17:58:35 +01:00
jesopo
35b97f836a Merge branch 'master' into feature/write-thread 2019-06-06 17:20:30 +01:00
jesopo
59eeee1030 message-tags are joined by ";", not "," 2019-06-06 17:19:27 +01:00
jesopo
a1ebe8035e Split read/write/process in to 3 different threads 2019-06-06 17:05:44 +01:00
jesopo
2ca4fd48f7 Make params arg for logging functions optional 2019-06-06 12:59:47 +01:00
jesopo
eb7d90bb00 message_tag_escape() message-tag values when .format()ing IRCLine 2019-06-06 09:29:17 +01:00
jesopo
8fe5098739 Make 'circular dependency' WARN more explicitly about 1-to-1 dependencies 2019-06-05 19:13:44 +01:00
jesopo
67b4aa69e2 check_purge() after removing a context as it could make a hook purgable 2019-06-05 16:56:02 +01:00
jesopo
2d46fe0cbf labels: Use BatchType to match, pass lines not line, batch ID isn't a label,
fire event on label response
2019-06-04 17:54:19 +01:00
jesopo
2470c1ec03 Add new BatchType object, to match like how Capability and MessageTag do 2019-06-04 17:51:55 +01:00
jesopo
8dbae6a5e9 Give SentLine (and preproc.send events) a new event object, to track events
related to a line after it is sent
2019-06-04 17:51:20 +01:00
jesopo
3ac01197f2 Send PING and PONG as 'immediate' lines 2019-06-04 14:31:34 +01:00
jesopo
4a4d0a37d7 Only return definitely-writen lines from IRCSocket._send, refactor in prep for
lines that request to be sent 'immediately'
2019-06-04 14:28:35 +01:00
jesopo
a802e66dcf Defer decoding http payload bytestring until after checking ContentType 2019-06-04 13:47:03 +01:00
jesopo
ef221f4165 v1.8.0 release 2019-06-03 13:30:39 +01:00
jesopo
c212d70b68 Hold on to BATCH args, allow event hooks to manipulate batches 2019-06-02 15:18:36 +01:00
jesopo
5204ac3300 fix some CAP related type hints 2019-06-02 10:14:09 +01:00
jesopo
f9f637e084 Remove IRCSendBatch, fix some batch-related type hints 2019-06-02 10:13:51 +01:00
jesopo
20c027fd0b check if we should enable write throttling before writing, clear _recent_sends
when we turn on throttling and only "turn on" throttling once
2019-06-01 22:28:57 +01:00
jesopo
b84d133500 add __str__ and __repr__ defs to IRCLine.ParsedLine 2019-06-01 22:28:37 +01:00
jesopo
e5c11f4aef add 'module-blacklist/whitelist' to bot.conf - use that as well as DB setting 2019-06-01 15:06:57 +01:00
jesopo
5077bad522 list()-ify filter() return, otherwise boolean checks against it are wrong 2019-06-01 15:05:57 +01:00
jesopo
c3454f2bfe available_capability returns str - fix type hint for this 2019-06-01 15:02:38 +01:00
jesopo
dc284bab4a Only enable write throttling when _write_buffer is empty
closes #59
2019-05-31 15:49:34 +01:00
jesopo
f2cf86b8c0 More explicitly require throttle_done() only for _queued_lines 2019-05-31 15:32:55 +01:00
jesopo
a3a61d2e86 Log server name when we see a _send failure 2019-05-30 15:46:01 +01:00
jesopo
367eb1c60e Make labeled-resposnes it's own module, tag and track every sent line 2019-05-30 15:36:10 +01:00
jesopo
f0dee5ebd6 Immutable arg default values leads to weird data persistence 2019-05-30 15:30:15 +01:00
jesopo
b8f778d7bd Only try to send QUITs on ctrl+c when we're connected - sys.exit otherwise 2019-05-29 16:11:47 +01:00
jesopo
768059fcf4 Switch resume.py to use the last server-time it saw, not last .recv() 2019-05-29 15:53:20 +01:00
jesopo
0be9046669 Pass str object to BeautifulSoup, not bytes. closes #56 2019-05-28 10:22:35 +01:00
jesopo
69a780b596 append ".py" when doing find_module on ModuleType.FILE 2019-05-27 16:56:13 +01:00
jesopo
786f04ea16 set changed = True when we pop a module with no dependencies left 2019-05-27 14:50:15 +01:00
jesopo
ce3a0668c6 Throw an exception when we detect a complex circular dependency 2019-05-27 11:42:47 +01:00
jesopo
5b780672a8 Enable TCP keepalives 2019-05-27 07:58:24 +01:00
jesopo
2a93a8f1dd Only check for unknown dependencies once 2019-05-26 20:27:17 +01:00
jesopo
38dd69a71e Only iterate a module's deps, not all modules, when checking for circular deps 2019-05-26 14:47:05 +01:00
jesopo
4048f63538 'cicular' -> 'circular', words are hard 2019-05-26 11:25:52 +01:00
jesopo
9815ddac8a 'cycular' -> 'cicular' 2019-05-26 06:54:29 +01:00
jesopo
69a1f42ecc Add basic comments for dependency-sorting system 2019-05-25 21:47:28 +01:00
jesopo
bb475d5cc8 Implement ordering modules by depends-on hashflag 2019-05-25 21:43:32 +01:00
jesopo
eeee2458d3 Fix utils.parse.hashflags type hints 2019-05-25 21:42:42 +01:00
jesopo
552902d462 Refactor ModuleManager 2019-05-25 18:24:50 +01:00
jesopo
d0634bb54e Don't store hashflags as a dict before returning them - allow duplicate keys 2019-05-25 12:58:07 +01:00
jesopo
a3a2c1e5a4 Store IRCSocket connect_time, show bytes read/write per second in stats.py 2019-05-24 17:32:59 +01:00
jesopo
503969abfd Bump version to v1.7.1 2019-05-24 06:52:25 +01:00
jesopo
b12298135e Bump version to v1.7.0 2019-05-23 19:10:22 +01:00
jesopo
6678076490 Remove column from server.add SQL (leftover from removing 'ipv4' column) 2019-05-21 10:45:24 +01:00
jesopo
ab1074cf4d Remove mention of ipv4 - detect address family automatically 2019-05-21 10:11:09 +01:00
jesopo
db33e12c8c Remove Capability.enabled() - it's unused 2019-05-20 16:36:02 +01:00
jesopo
b12c38c326 typing.List -> typing.Sequence 2019-05-20 16:35:50 +01:00
jesopo
bdd161256d has_capability -> has_capability_str, add new has_capability 2019-05-20 16:33:32 +01:00
jesopo
3ad83655d5 ParsedLine already deals with preventing newlines 2019-05-20 16:19:37 +01:00
jesopo
e752b60f6c use fnmatchcase( so the strings are not case-"normalised" 2019-05-19 16:28:46 +01:00
jesopo
c607a0e67c Implement utils.irc.hostmask_match for glob-like hostmask matching 2019-05-19 16:24:38 +01:00
jesopo
58d6b16744 Remove _name and _draft_name (unused) and add Capability.copy() 2019-05-19 11:00:58 +01:00
jesopo
7671dd2086 Switch back to events.name defaulting to None, use typing.cast to fix linting
error
2019-05-18 21:14:28 +01:00
jesopo
105351d6f3 Add a timestamp to recent_sends for EACH line sent 2019-05-18 19:08:34 +01:00
jesopo
d64d12f8fd give EventCallbacks their event name 2019-05-18 18:35:23 +01:00
jesopo
eccd43d357 Add a way to not put spaces between docstring lines when stripping \n 2019-05-18 18:34:27 +01:00
jesopo
bea8556329 Bump version to v1.6.0 2019-05-17 13:39:55 +01:00
jesopo
7547eee96d Catch server version string, from RPL_MYINFO 2019-05-15 17:12:21 +01:00
jesopo
a80eda614d Add IRCBot.SOURCE, use it in ctcp.py 2019-05-15 10:30:36 +01:00
jesopo
38ba656bda Add type hints to utils.irc.MessageTag 2019-05-14 23:07:42 +01:00
jesopo
421d9c10c7 Add utils.irc.MessageTag and use it for both draft and ratified msgid 2019-05-14 13:02:45 +01:00
jesopo
1c296826d7 Move module black/white list to IRCBot, allow "safe" loading of all modules 2019-05-12 14:10:59 +01:00
jesopo
d291cd5063 Revamp how CAPs are tracked through REQ and ACK/NAK etc 2019-05-11 18:22:40 +01:00
jesopo
295f7a751c Refactor CAPs in to objects 2019-05-11 15:11:09 +01:00
jesopo
091818fa32 Hold context in EventCallback objects, add name<->context translation in
ModuleManager
2019-05-10 16:11:22 +01:00
jesopo
f7eae1a978 Tokenize IRC data as soon as it comes out of IRCServer 2019-05-09 10:36:33 +01:00
jesopo
920dce0221 Add IRCServer.has_user_id, to check if we've seen a user before 2019-05-05 00:16:37 +01:00
Patrick Nappa
2c344c9ddd forgot the beautiful % 2019-05-03 13:50:51 +10:00
Patrick Nappa
471c11e229 ensure that non-url characters not separated by whitespace aren't consumed 2019-05-03 13:43:08 +10:00
jesopo
e844004ba1 Fix reconnect() type hint issues 2019-05-01 17:13:55 +01:00
jesopo
aa1b457632 Change TRIGGER_RETURN and TRIGGER_EXCEPTION to an enum 2019-05-01 17:13:41 +01:00
jesopo
992ab15394 Bump version to v1.5.0 2019-04-30 12:05:59 +01:00
jesopo
280e647a84 Only pass through args from connection params when reconnecting 2019-04-30 12:05:36 +01:00
jesopo
0afe798b83 Support parsing iso8601 with microseconds 2019-04-28 12:11:48 +01:00
jesopo
74c16a1bbe Actually respect default return in Exports.get_one 2019-04-27 14:49:18 +01:00
jesopo
bdcb4b5db2 Add missing ":" 2019-04-25 17:50:41 +01:00
jesopo
1240b154cb Support interfaces that don't have AF_INET and/or AF_INET6 2019-04-25 17:48:51 +01:00
jesopo
7643a962bd Refuse to get the title for any url that points locall 2019-04-25 15:58:58 +01:00
jesopo
dffee4d223 Move REGEX_URL out of isgd.py and title.py in to utils.http 2019-04-24 15:46:54 +01:00
jesopo
e095c56f77 Record and show when a !to was created 2019-04-24 14:32:56 +01:00
jesopo
dc102f258d Add Database.servers.get_by_alias, move IRCBot.get_server to
IRCBot.get_server_by_id, add IRCBot.get_server_by_alias and change
!connect/!disconnect to take aliases instead of IDs
2019-04-24 12:07:30 +01:00
jesopo
bd4fdfdc7b Add UNIQUE constraint for alias on servers table 2019-04-24 11:49:54 +01:00
jesopo
032f6fbc3b IRCServer.alias is no longer optional 2019-04-24 11:45:21 +01:00
jesopo
87340bcbf9 change utils.iso8601_format to default to no milliseconds, switch to using
utils.iso8601 functions in badges.py
2019-04-23 21:27:43 +01:00
jesopo
ee8c7813f7 Add IRCServer.send_raw so modules don't have to parse messages before sending
them
2019-04-16 13:47:45 +01:00
jesopo
34848324d5 Bump version to v1.4.0 2019-04-16 09:59:40 +01:00
jesopo
272b60842e 'IRCChannels._get_id' -> 'IRCChannels.get_id' 2019-04-07 13:59:53 +01:00
jesopo
0eaeca8f83 Put spaces between units in output from utils.to_pretty_time 2019-03-21 17:59:42 +00:00
jesopo
10ca8a1219 Add IRCUser.hostmask() to format nick/user/host in to a hostmask 2019-03-12 10:39:54 +00:00
jesopo
5d7f017c9c Enum values shouldn't be all upper case 2019-03-10 13:14:25 +00:00
jesopo
1fcbdd305c 'failed to connect' log line needs 2 "%s"s 2019-03-09 20:21:15 +00:00
jesopo
5c5b4ef139 Handle negative (end-relative) indexes being given to IRCArgs.get 2019-03-08 23:35:52 +00:00
jesopo
f1348e5679 Handle IRCArgs being empty strings (e.g. 'PRIVMSG #test :') 2019-03-08 23:23:09 +00:00
jesopo
b3472c009a Only log exception message, not full stacktrace, when a connect fails 2019-03-08 10:12:01 +00:00
jesopo
6b59830a6e Only print ANSI reset characters when appropriate 2019-03-06 21:48:31 +00:00
jesopo
1b7a8bc896 Log content of lines that need fallback encoding 2019-03-06 17:19:37 +00:00
jesopo
c842c459f4 Specifically only catch UnicodeDecodeError in IRCSocket.read 2019-03-06 17:02:58 +00:00
jesopo
11c4d70156 add IRCServer.clear_send_buffer() to clear queued lines 2019-03-05 11:35:24 +00:00
jesopo
91c2ab03ba add IRCServer.send_enabled, to prevent sending after QUIT in signals.py 2019-03-05 11:29:46 +00:00
jesopo
b43a5a7c74 Add -N to start.py to disable to-file logging 2019-03-04 19:35:18 +00:00
jesopo
7a3db82300 Add IRCServer.has_capability and use it throughout line_handler 2019-03-03 22:38:34 +00:00
jesopo
197ae2e053 Raise a specific exception in utils.http.request for "wrong content type" 2019-02-28 23:28:45 +00:00
jesopo
948c86adbc Need to str() Hostmask objects in ParsedLine.format() 2019-02-28 16:22:17 +00:00
jesopo
9335ca5d16 Treat both a and a= as None for message-tags 2019-02-27 22:20:01 +00:00
jesopo
d16046fb49 Simplify ParsedLine._tag_str and ParsedLine.format() 2019-02-27 22:14:53 +00:00
jesopo
846b881e52 Throw ValueError when utils.http.request tries to soup non-html/xml data 2019-02-27 15:16:08 +00:00
jesopo
cfaf6864fc Don't try to parse non-html/xml stuff with BeautifulSoup 2019-02-26 11:18:50 +00:00
jesopo
5aaf6eb7df Bump version to v1.2.1 2019-02-25 21:47:36 +00:00
jesopo
56f6511ad3 Critical security fix: truncate IRCLine.ParsedLine.format() at newline 2019-02-25 21:46:23 +00:00
jesopo
d627ed49e2 Pull "is main thread" logic out to utils, force Database to be accessed on main
thread
2019-02-25 10:36:17 +00:00
jesopo
faa305f2e8 Add -m/-M args to ./start.py that call command_line on individual modules 2019-02-24 10:43:46 +00:00
jesopo
276d753711 Change --verbose short to -V, add --version/-v, add IRCBot.VERSION 2019-02-24 08:37:42 +00:00
jesopo
8d55319f56 Rename IRCLine.Line to IRCLine.SentLine, for clarity 2019-02-24 08:25:12 +00:00
jesopo
1473f41b03 Fire preprocess.send per-command - use this to only strip colors from ParsedLine
objects for PRIVMSG and NOTICE
2019-02-23 21:40:11 +00:00
jesopo
5baa688fbc Make IRCArgs mutable 2019-02-23 21:39:46 +00:00
jesopo
8c94bcf6ca Move utils.irc.IRCParsedLine to IRCLine.ParsedLine, improve truncation
mechanism, don't convert sent line from ParsedLine to text to ParsedLine for
line_handler handling
2019-02-23 21:33:04 +00:00
jesopo
c6699c509e .upper() command in IRCParsedLine.format() 2019-02-23 16:11:26 +00:00
jesopo
54218b747f Only allow the last arg of a formatted line to be :trailing 2019-02-23 16:07:20 +00:00
jesopo
8b54046ca4 Add target typehint on IRCServer.send_tagmsg, add send_tagmsg to IRCChannel/IRCUser 2019-02-22 22:34:54 +00:00
jesopo
9d72cbca73 Keep track of a user's away message, not just whether they're away or not 2019-02-22 22:26:50 +00:00
jesopo
8a0fd009e4 Also unload submodules within packages (ModuleManager.py) 2019-02-22 17:58:53 +00:00
jesopo
47c2cbb0fa Split line_handler.py out in to different files for different categories 2019-02-22 11:23:36 +00:00
jesopo
62eab40968 Revert "Treat both a and a= as having a value of None in message-tags (utils.irc)"
This reverts commit e7ec4b5716.
2019-02-21 07:29:19 +00:00
jesopo
e7ec4b5716 Treat both a and a= as having a value of None in message-tags (utils.irc) 2019-02-20 22:26:31 +00:00
jesopo
deedab7248 Add IRCServer.send_joins, a nicer interface than manually ",".joining 2019-02-20 17:08:30 +00:00
jesopo
ddb69685d3 again, r"\" isn't valid. 2019-02-20 16:53:40 +00:00
jesopo
e343bf3e6a Check throttle space when queueing more data not whether there's no queued data 2019-02-20 16:52:45 +00:00
jesopo
98215f66eb r"\" isn't valid - use "\\" (utils.irc) 2019-02-20 16:52:14 +00:00
jesopo
c1881fbafb Remove '\' from post-unescaped message-tags 2019-02-20 16:34:14 +00:00
jesopo
47841ed154 don't replace '\\' with '\\' with message-tag unescape 2019-02-20 16:33:48 +00:00
jesopo
81d82413d4 draft/message-tags-0.3 (JSON tags) was rejected 2019-02-20 14:46:40 +00:00
jesopo
577fae7cea Don't pass None around as tag default, fix some missing return type args 2019-02-19 15:57:00 +00:00
jesopo
3f8ac871ed typo, 'utls' -> 'utils' (utils.irc) 2019-02-19 15:44:23 +00:00
jesopo
114d1054a5 Add .message( and .notice( to IRCSendBatch 2019-02-19 15:41:17 +00:00
jesopo
bc772ef5cc Default IRCParsedLine.tags to empty dict, not None 2019-02-19 15:40:56 +00:00
jesopo
53e5a7fe7e contextualise JOIN key check, otherwise it doesn't send channel_name 2019-02-19 09:32:17 +00:00
jesopo
9f946e236d copy paste fail, batch end should be "-" not "+" 2019-02-19 08:25:25 +00:00
jesopo
81ae0cc889 Add make_batch and send_batch to IRCServer 2019-02-18 23:16:47 +00:00
jesopo
b76b153672 Add batch_start and batch_end to utils.irc.protocol 2019-02-18 23:11:36 +00:00
jesopo
509a7ff42e Default tags to null for utils.irc.protocol's message and notice 2019-02-18 23:06:41 +00:00
jesopo
07cb14d98c utils.irc.protocol.join()'s keys param should be typing.Optional 2019-02-18 23:03:21 +00:00
jesopo
3bb917b619 Add src/utils/irc/__init__.py that should have been added some commits ago 2019-02-18 23:00:50 +00:00