Commit graph

1150 commits

Author SHA1 Message Date
jesopo
dc4adc4d71 add non-consuming spec arg types for privateonly and channelonly 2020-01-27 00:28:30 +00:00
jesopo
2f5e2a8345 .append() doesn't work on dict, use same code for missing optional 2020-01-26 16:05:32 +00:00
jesopo
223fe9fc7c fix channel_access spec arg indexes 2020-01-26 15:41:04 +00:00
jesopo
ba1800b207 refactor command_spec.py 2020-01-26 15:40:36 +00:00
jesopo
23d3ba5e29 add tstring spec type, string with trimmed consecutive spaces 2020-01-26 11:24:57 +00:00
jesopo
c33f8bbaf8 ?time->?duration, remove now unneeded usage kwarg 2020-01-26 02:52:38 +00:00
jesopo
73ad5c5c1b add nuser spec arg type; to get a user, new or not 2020-01-26 02:51:18 +00:00
jesopo
6c510d2332 add rchannel spec arg to !access 2020-01-26 02:49:20 +00:00
jesopo
184628ddfc we need a fresh mutable args copy for each spec 2020-01-26 02:49:05 +00:00
jesopo
27ba8e8da8 update channel_access.py to use command spec language 2020-01-26 02:41:39 +00:00
jesopo
2ae47364c0 support multiple specs per command 2020-01-26 02:41:24 +00:00
jesopo
41e1115999 fix typehinting issues 2020-01-26 02:09:48 +00:00
jesopo
e0686ef7b4 support command spec literals 2020-01-26 02:01:18 +00:00
jesopo
c3bb46ad23 only show "not enough arguments" n>len(args) 2020-01-26 02:00:43 +00:00
jesopo
b83e066dad show topic timestamp in a more human readable format 2020-01-26 00:49:31 +00:00
jesopo
1d1e2d95a9 split utils/parse.py in to multiple files 2020-01-26 00:06:47 +00:00
jesopo
b24d62c0e6 update !ignore to use command specs 2020-01-25 23:59:00 +00:00
jesopo
ced3bb23da "time" spec arg renamed to "duration" 2020-01-25 23:58:09 +00:00
jesopo
1a8a4ac9d4 support spec arg "context" (e.g. private only), marked exported as private 2020-01-25 23:57:27 +00:00
jesopo
6a3702577f when available, use command spec for !help usage 2020-01-25 23:15:02 +00:00
jesopo
0c28d63822 add utils.parse.argument_spec_human() for usage strings 2020-01-25 22:56:56 +00:00
jesopo
bd33ea5d8a implement default spec argument types 2020-01-25 22:56:06 +00:00
jesopo
478223f88c support type names of spec arguments 2020-01-25 21:17:35 +00:00
jesopo
341b314104 change command specs to be compiled at runtime by a decorator 2020-01-25 14:01:11 +00:00
jesopo
264e544ce5 support !... as "one or more", show "not enough args" error 2020-01-25 11:33:09 +00:00
jesopo
1d9621022c remove debug print 2020-01-25 11:32:49 +00:00
jesopo
5722a567a1 fix format_token_replace for $$ 2020-01-25 11:32:01 +00:00
jesopo
09fa9363b3 support e.g. "!r~channel" spec to change the context of "!cuser" 2020-01-24 17:00:55 +00:00
jesopo
241382fe66 add some comments about all the command_spec spec types 2020-01-24 16:50:25 +00:00
jesopo
e16831cc83 better "!user" spec error 2020-01-24 16:42:23 +00:00
jesopo
f51b06aae1 check "channel" coming from command_spec.py parsing (check_mode, channel_access) 2020-01-24 16:26:53 +00:00
jesopo
f0d8853549 implement "important" command spec pieces, esp. for channel perms 2020-01-24 16:25:50 +00:00
jesopo
def6a019d6 don't args[0] for rchannel when [], better rchannel error 2020-01-24 15:35:05 +00:00
jesopo
47cb5eaab8 utils.parse.timed_args() min_args should be optional 2020-01-24 15:30:32 +00:00
jesopo
4e2f463d39 add ruser/rchannel (r for relevant) to command_spec.py 2020-01-24 15:29:13 +00:00
jesopo
52c3cab627 still append None when an optional spec is missed 2020-01-24 14:27:47 +00:00
jesopo
fa98b72fd5 first draft of command_spec.py 2020-01-24 14:24:54 +00:00
jesopo
a9a9cd816b channel.send_mode() BEFORE calling self.join event 2020-01-24 10:37:41 +00:00
jesopo
cf544d66f9 extraneous newline 2020-01-23 17:41:57 +00:00
jesopo
f6e6dd0339 remove received.server-notice related code 2020-01-23 14:08:58 +00:00
jesopo
d919e5c345 simplify snotice detection, handle as normal NOTICE 2020-01-23 13:10:45 +00:00
jesopo
ab2ed90ef9 set_own_nickname before sending self.nick event 2020-01-23 12:51:18 +00:00
jesopo
4515cf84e1 support WATCH as well as MONITOR nick nick_regain.py 2020-01-23 12:50:58 +00:00
jesopo
022eed84f6 pull mode for RPL_(ENDOF)QUIETLIST from args[2] 2020-01-23 12:34:18 +00:00
jesopo
ef2d80511d only check missed modes if our mode changes and MODE #chan responds 2020-01-23 12:23:27 +00:00
jesopo
cded6b6877 only query missing list modes on MODE when we're seen ENDOFWHO 2020-01-23 12:09:45 +00:00
jesopo
9ac2fe96fe changed failed list modes after ENDOFWHO, not when our mode changes 2020-01-23 11:45:51 +00:00
jesopo
007fd1206c add typehint for IRCChannel.mode_lists 2020-01-22 18:01:22 +00:00
jesopo
2a33b25930 correctly support INVEX and EXCEPTS lists 2020-01-22 17:58:12 +00:00
jesopo
811b85d0f9 move mode list (beIq e.g.) to it's own module, mode_lists.py 2020-01-22 17:41:20 +00:00
jesopo
175e8c0a16 change utils.irc.strip_font() to remove tokens, no regex 2020-01-22 16:32:21 +00:00
jesopo
f79aa036f2 fix hostmask_match_many typehint 2020-01-22 15:04:48 +00:00
jesopo
ade5cbb1f3 add an optional mask pattern arg to !clear 2020-01-22 15:00:59 +00:00
jesopo
64848f5ab7 add a special "require_mode" arg; "highest" meaning "highest mode possible" 2020-01-22 14:12:48 +00:00
jesopo
b6f18f809c add a special "require_mode" arg; "admin" meaning "above op if available" 2020-01-22 14:10:45 +00:00
jesopo
5258b8cc8f typo; 'resaon' -> 'reason' 2020-01-22 12:46:07 +00:00
jesopo
cabc5942b4 server should be IRCServer, not IRCChannels 2020-01-22 12:28:05 +00:00
jesopo
1c5d67f836 parse proposed ISUPPORT QUIET token 2020-01-22 11:19:44 +00:00
jesopo
369160d46f allow requesting utils.irc.color() to not add terminating code 2020-01-21 16:40:01 +00:00
jesopo
c336fdf93b split permission for !alias/!balias in to two 2020-01-21 16:14:01 +00:00
jesopo
fb457c52fb IRCBuffer.find's not_pattern arg should be optional 2020-01-20 16:28:50 +00:00
jesopo
119066b549 user varaible doesn't exist in invite formatting code
closes #231
2020-01-20 14:17:50 +00:00
jesopo
6b0bb512ef colourise server name for server notice formatting 2020-01-20 14:12:37 +00:00
jesopo
0abcc173cd {~TNICK}, not {TNICK} 2020-01-20 14:00:20 +00:00
jesopo
5a0a340e44 better formatting for server notices 2020-01-20 13:48:50 +00:00
jesopo
1f2beef0f5 pass :source or connection_params.hostname through server-notice event 2020-01-20 13:48:29 +00:00
jesopo
8fbf91a2f0 show account and realname in JOIN formatting when available 2020-01-20 13:42:36 +00:00
jesopo
c6d913e218 provide {NICK} as well as {~NICK} as default formatting args 2020-01-20 13:25:33 +00:00
jesopo
dba3f7abc3 .zfill(3) milliseconds in utils.datetime.datetime_human 2020-01-20 13:24:58 +00:00
jesopo
cb73507c5e use a TimeSpec system to request milliseconds in utils.datetime 2020-01-20 13:20:26 +00:00
jesopo
fbe4c93c58 don't overwrite line in MOTD formatting 2020-01-20 13:20:08 +00:00
jesopo
50be75a5e2 also do .format(**) when there's no user object 2020-01-20 13:19:47 +00:00
jesopo
0eb92278cc do all user-provided formatting as {VAR} formatting
otherwise, e.g., a PRIVMSG with {~NICK} will be replaced with user nickname
2020-01-20 12:07:04 +00:00
jesopo
631e669426 _on_topic doesn't always have a user 2020-01-17 18:13:35 +00:00
jesopo
ba5d79c953 fix utils.datetime.iso8601_parse linting error 2020-01-17 16:37:31 +00:00
jesopo
9efe952a9f BufferLine.id should be a string 2020-01-17 16:37:22 +00:00
jesopo
b4e3ee5d0e pass draft/delete events through to format_activity/print_activity 2020-01-17 16:28:48 +00:00
jesopo
95668f2b8b give BufferLine.id default value, overwrite in ircv3_msgid.py 2020-01-17 16:28:23 +00:00
jesopo
5c7026886d overwrite BufferLine.timestamp with ircv3 server-time when available 2020-01-17 15:58:37 +00:00
jesopo
3e574f3c52 add BufferLine.timestamp (datetime.datetime object) 2020-01-17 15:58:08 +00:00
jesopo
e4d71f6c0c add dateutil as a dependency, use it in utils.datetime.iso8601_parse 2020-01-17 15:57:30 +00:00
jesopo
ae7c6d8572 export function for formatting activity lines 2020-01-17 15:36:34 +00:00
jesopo
e3070f52ff refactor format_activity to use {FORMATTING} for maybe-colored things 2020-01-17 15:31:12 +00:00
jesopo
a79f866269 tidy up IRCBuffer.find, respect line.deleted there too 2020-01-17 14:27:45 +00:00
jesopo
44644dcd56 allow BufferLines to be marked as deleted 2020-01-17 14:19:46 +00:00
jesopo
f8b509ef94 give ever BufferLine an ID (IRCv3 msgid or uuid4()) 2020-01-17 14:19:30 +00:00
jesopo
10006a9986 catching account-tag should be PRIORITY_HIGH 2020-01-16 09:50:37 +00:00
jesopo
c180900929 pay attention to account tag on PRIVMSGs 2020-01-16 09:47:57 +00:00
jesopo
21694c39a5 allow !part to work for "current channel" when op/!access 2020-01-13 20:06:32 +00:00
jesopo
6633427cb7 send expect_output on private command events too 2020-01-11 19:20:30 +00:00
jesopo
d06d74efb9 default pattern-based commands to expect_output=False 2020-01-11 19:10:19 +00:00
jesopo
ba958f341b also Accept-Language "en" in HTTP requests (0.5 weight) 2020-01-11 17:55:18 +00:00
jesopo
366a7bf326 Revert "explicitly .close() task in http.request_many()"
This reverts commit 7478d62b77.
2020-01-06 17:17:49 +00:00
jesopo
7478d62b77 explicitly .close() task in http.request_many() 2020-01-06 17:04:30 +00:00
jesopo
e9f82fc645 sort variable $names descending so longer ones are caught first 2020-01-03 06:59:22 +00:00
jesopo
9efb0b05fc by default, don't trigger command.regex events when in a statusmsg 2020-01-01 10:04:32 +00:00
jesopo
627b17e894 pass through (as well as stripping) statusmsg characters to events 2020-01-01 10:04:06 +00:00
jesopo
9dc6069e06 add missing closing paren to bitbot's User Agent 2019-12-29 08:00:05 +00:00
jesopo
e3455f94fb only respect CASEMAPPING when it's not an empty string 2019-12-27 21:34:08 +00:00
jesopo
cff1a55fe6 actually replace "$$" with "$" 2019-12-27 13:55:55 +00:00
jesopo
f2eba715b4 i should shift righwards also when finding double sigil 2019-12-27 13:50:12 +00:00
jesopo
a9c5b1dd83 remove extraneous space in "MONITOR -" command 2019-12-25 01:42:21 +00:00
jesopo
a5e7767f80 refactor nick_regain, also look for NICK/QUIT for regain 2019-12-25 01:41:01 +00:00
jesopo
b2c5ad041c simplify token replace, catch one-char end-of-string tokens 2019-12-21 21:40:44 +00:00
jesopo
2218d4a888 use utils.parse.format_token_replace() in aliases.py 2019-12-21 21:17:08 +00:00
jesopo
bc1c77d8a8 implement standardised $token replacement in utils.parse 2019-12-21 21:16:50 +00:00
jesopo
b0a71f8bb2 don't have [''] as args_split when there's no args (for alias) 2019-12-21 21:16:14 +00:00
jesopo
3c77793490 only look at 329 when it's a channel we know we are in 2019-12-20 22:03:40 +00:00
jesopo
a2ac26c072 use +=timedelta(minutes=1) when calculating next minute
closes #223
2019-12-19 14:02:55 +00:00
jesopo
e458127fb5 move --database/data-dir/log-dir to bot.conf, do some work for diff db engines 2019-12-19 13:56:58 +00:00
jesopo
cfcccdd37b we no longer use DECODE_CONTENT_TYPES 2019-12-18 20:04:14 +00:00
jesopo
1fedaf02bd 'hostmaks' -> 'hostmask' typo in code for !hostmask add 2019-12-18 19:36:52 +00:00
jesopo
ddcf54e751 add kwarg name replacements to aliases.py, use it for $NICK$ 2019-12-17 14:30:14 +00:00
jesopo
00a8129634 pass user on get.command events, so e.g. aliases know user nicknames 2019-12-17 14:29:37 +00:00
jesopo
cc02595056 move internal.identified event call to _has_identified (covers hostmasks and
nickserv)
2019-12-14 21:40:49 +00:00
jesopo
f6273a5a67 "_match" -> "_schedule_match_part" typo 2019-12-13 17:16:02 +00:00
jesopo
8bf6db7fe5 use zip() instead of enumerate() and indexing 2019-12-12 12:10:08 +00:00
jesopo
e58e5e0691 more brackets in blob of math, just in case 2019-12-12 12:07:42 +00:00
jesopo
2084285480 support cron schedule range values 2019-12-12 12:06:02 +00:00
jesopo
48bab203bf comma-separated cron schedule check should be first 2019-12-12 12:02:27 +00:00
jesopo
80f0a3d94c refector cron.py and support comma-separated schedule pieces 2019-12-12 12:00:27 +00:00
jesopo
60db9ff389 first draft on cron module 2019-12-11 15:43:17 +00:00
jesopo
ff050b3583 send.stdout should default to thinking it is in-channel 2019-12-11 11:19:42 +00:00
jesopo
5a2905de01 allow Request objects to specify their timeout 2019-12-11 11:18:19 +00:00
jesopo
6f8338b7b5 allow users to set command-method for PMs with them 2019-12-10 17:11:44 +00:00
jesopo
b4b998b7d4 default command responses in PM to use NOTICE 2019-12-10 16:59:00 +00:00
jesopo
cffbcad430 support bot-wide aliases with !balias
closes #212
2019-12-10 11:28:09 +00:00
jesopo
734aec179f move aliases.py to core_modules 2019-12-10 11:23:34 +00:00
jesopo
a3bde5e682 fix ModuleManager.find_module() - don't set path until it's actually found 2019-12-10 11:08:44 +00:00
jesopo
58c09f7342 fix typos, type hinting and missed changes in ModuleManager 2019-12-10 05:32:55 +00:00
jesopo
638eee0d68 move core modules to src/core_modules, make them uneffected by white/black list 2019-12-10 05:27:35 +00:00
jesopo
9d16f7d523 move sys.exit() codes to an enum in utils.consts 2019-12-10 05:26:16 +00:00
jesopo
3028759c86 use get_list and set_list to move dynamic module en/disabling to bot.conf 2019-12-07 11:07:43 +00:00
jesopo
3bf2f86702 added get_list() and set_list() to src/Config.py 2019-12-07 11:05:32 +00:00
jesopo
e08bac9312 add src/Config.py.__delitem__ 2019-12-07 11:05:13 +00:00
jesopo
a98dc6e0a6 add src/Config.py.__setitem__ 2019-12-07 10:51:04 +00:00
jesopo
fc069d6da2 fix src/Config.py type hinting 2019-12-07 10:50:50 +00:00
jesopo
7274d1bf28 add ability to save config file 2019-12-07 10:42:43 +00:00
jesopo
374cc307b1 remove -m/-M and BaseModule.command_line - it doesn't work any more 2019-12-07 10:23:17 +00:00
jesopo
b212714561 Revert "add utils.parse.shortencode() and utils.parse.shortdecode - effectively base62"
This reverts commit e71f3bbc36.
2019-12-06 14:29:26 +00:00
jesopo
e71f3bbc36 add utils.parse.shortencode() and utils.parse.shortdecode - effectively base62 2019-12-06 12:10:41 +00:00
jesopo
b889a9f841 add utils.http.Session object, to preserve cookies across requests 2019-12-03 13:00:43 +00:00
jesopo
499e83a1cb refactor karma to be per-user. added data migration script for this 2019-12-01 07:07:28 +00:00
jesopo
3ce947bb77 add database.users.get_nickname, to get nickname from ID 2019-12-01 07:05:17 +00:00
jesopo
b385323386 fix database.user_settings.find logic 2019-12-01 07:05:01 +00:00
jesopo
91c3688018 only add BufferLine to buffer *after* received.message.* callback 2019-11-30 20:25:52 +00:00
jesopo
d688636909 rework permissions module to precompile hostmasks 2019-11-30 19:32:38 +00:00
jesopo
411f66324d use ANSI_RESET in utils.irc.parse_format, not all the different resets 2019-11-28 15:42:12 +00:00
jesopo
c79bd6d0ba utils.http.Response.decode() should default to detected encoding 2019-11-28 07:35:16 +00:00
jesopo
747ba5c646 add IRCLine.parse_human() to allow for "!raw /msg jesopo hello" 2019-11-27 17:38:17 +00:00
jesopo
40a459a83c add Buffer.get_all 2019-11-27 12:59:50 +00:00
jesopo
2139c99562 fix BufferLine.notes definition 2019-11-27 12:59:36 +00:00
jesopo
710b711c70 dataclass-ify IRCBuffer.BufferLine, add .notes={} 2019-11-27 12:07:15 +00:00
jesopo
9972125b24 remove IRCBuffer.skip_next (not used), pass buffer lines on message events 2019-11-27 12:06:57 +00:00
jesopo
e4a5bd01e9 explicitly use "lxml" for finding page encoding 2019-11-26 14:34:48 +00:00
jesopo
8e9da0d681 _find_encoding takes bytes and soupifies now 2019-11-26 13:58:37 +00:00
jesopo
c898bc4be1 utils.http.request_many() shouldn't decode data for Response 2019-11-26 13:54:17 +00:00
jesopo
2d21dfa229 utils.http.Response.data should always be bytes - add .decode and .soup 2019-11-26 13:42:01 +00:00
jesopo
ed775ddbe3 remove parser from utils.http.Request, add Request.soup() 2019-11-26 11:35:56 +00:00
jesopo
93aea08818 utils.datetime.datetime_utcnow() -> utils.datetime.utcnow() 2019-11-25 18:18:09 +00:00
jesopo
6a6e789ec9 add cookies and .json() to utils.http.Response objects 2019-11-25 18:17:30 +00:00
jesopo
ab8bc65cc9 change utils.http.Request to be a dataclass 2019-11-25 13:42:10 +00:00
jesopo
5730d6fe59 refactor commands (mostly stdout/stderr) and split typing/reply out
closes #208
2019-11-22 16:23:30 +00:00
jesopo
2dfc55fb9f refactor permissions and allow hostmasks to be assigned to accounts 2019-11-21 15:49:08 +00:00
jesopo
9f8c5acf52 add a way to execute commands through bitbotd (use for master-password) 2019-11-21 10:39:26 +00:00
jesopo
4d30263315 give bitbot a unique User-Agent
closes #206
2019-11-20 14:42:34 +00:00
jesopo
11c3104d02 move things like IRCBot.VERSION to before imports (for utils.http) 2019-11-20 14:41:14 +00:00
jesopo
bd176240d6 consecutive HASH_STOP chars at start shouldn't count as a stop 2019-11-19 14:45:47 +00:00
jesopo
554f21a84c HASH_STOP should still be respected if last character 2019-11-19 14:43:24 +00:00
jesopo
bc6b1dda47 chance src/Cache.py from time.monotonic() to time.time() 2019-11-19 11:41:50 +00:00
jesopo
65023dc84b move "+5m" syntax parsing out to utils.parse 2019-11-18 15:57:23 +00:00
jesopo
fe25c6bc26 switch some utils.irc functions to use f-strings 2019-11-18 14:16:30 +00:00
jesopo
d89a3125ab truncate nickname hash operations to 64bit 2019-11-18 14:09:47 +00:00
jesopo
a8b1bd95f7 implement weechat-style djb2 colour hashing 2019-11-18 13:51:55 +00:00
jesopo
a7e21abfad import missing comma, 'Events'->'Event' 2019-11-18 12:10:20 +00:00
jesopo
06161b326c remove unused imports in src/utils/__init__.py 2019-11-18 12:09:18 +00:00
jesopo
9c4902dcfe "EventsResultsError"->"EventResultsError", move errors to utils.error 2019-11-18 12:06:59 +00:00
jesopo
5d55086847 move utils.consts.BITBOT_MAGIC to utils.decorators 2019-11-15 14:09:35 +00:00
jesopo
5d01db8514 move all datetime-related code from utils/__init__ to utils.datetime 2019-11-15 13:59:09 +00:00
jesopo
5e8cf06a45 dont expose has_magic/get_magic in utils/__init__.py, ref directly 2019-11-15 13:41:03 +00:00
jesopo
bfcf40edd7 split some stuff out of utils/__init__.py 2019-11-15 13:39:24 +00:00
jesopo
2cb55306c3 show first-words datestamp on !words output 2019-11-15 12:13:16 +00:00
jesopo
c9cb8c8805 set info log rolling backup count to 1 (0 means "keep all backups") 2019-11-14 13:35:23 +00:00
jesopo
a1e9aabb84 add typehinting for foreground/background 2019-11-13 10:47:58 +00:00
jesopo
5d2dd9178f only set color_finished=True when is_background, otherwise next char sets it 2019-11-13 10:43:15 +00:00
jesopo
8a8bd8a77e colorize nicks on JOIN formatting 2019-11-11 12:49:45 +00:00
jesopo
b7bfd414be hash_colorize code should first be looked up in HASH_COLORS 2019-11-11 12:48:37 +00:00
jesopo
727fb3427d .lower() strings when hash-colorizing them 2019-11-11 12:40:36 +00:00
jesopo
ac30f8d4cc don't use hash() for hashed colorising as it's not stable through restarts 2019-11-11 12:13:46 +00:00
jesopo
2ad8623eb3 add utils.irc.hash_colorize() to color a string by the string's hash 2019-11-11 12:06:16 +00:00
jesopo
98183fe4b9 add IRCArgs.append func 2019-11-08 17:41:18 +00:00
jesopo
5fcf18313e silently eat Control socket .send() failures 2019-11-08 13:38:07 +00:00
jesopo
09fe1c5a70 don't stop parsing colors at comma 2019-11-04 13:33:10 +00:00
jesopo
bcdffacab5 add on_pause() and on_resume() for module - use in rest_api.py 2019-11-04 10:52:41 +00:00
jesopo
2b001e1ec6 ' ' -> " " 2019-10-31 13:06:26 +00:00
Valentin Lorentz
fbf8cd1a16 Fix type errors detected by 'mypy --ignore-missing-imports src'. 2019-10-30 22:26:59 +01:00
jesopo
9958c9169d fix _line() related type hinting issues in IRCServer.py 2019-10-30 13:46:29 +00:00
jesopo
3634b72622 add utils.date_human() - use it in badges.py 2019-10-30 10:25:07 +00:00
jesopo
4d85c3d1e0 utils.parse doesn't need to import utils 2019-10-29 18:03:03 +00:00
jesopo
080bcef3a0 'from src.utils import' -> 'from . import' 2019-10-29 18:02:50 +00:00