3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 19:49:24 +01:00
Commit Graph

223 Commits

Author SHA1 Message Date
James Lu
5d10ee39be ServiceBot: make displaying unknown command errors optional
Closes #441.
2017-03-28 22:18:51 -07:00
James Lu
c19ea74fb4 ServiceBot: ignore attempts to call empty commands 2017-03-20 22:22:43 -07:00
James Lu
f6d9765f87 core: implement module loading from user-defined directories
Closes #350.
2017-03-08 22:31:57 -08:00
James Lu
805a0502d2 utils: add an alias (utils.IRCParser.REMAINDER) to argparse.REMAINDER
Reported by @IotaSpencer.
2017-03-08 10:02:46 -08:00
James Lu
225b0ac8b2 ServiceBot: catch InvalidArgumentsError for prettier error display on IRC 2017-03-06 16:30:43 -08:00
James Lu
ca93d1ad70 IRCParser: show an error when using "command --help" instead of silently outputting help text in the console 2017-03-06 16:30:43 -08:00
James Lu
76d74ab9bb SECURITY: prevent DoS when calling --help on commands using IRCParser
argparse's default behaviour is to exit after displaying --help and --version information. However, doing so freezes the current IRC listener and essentially allows for DoS via IRC...
This bug does not affect any released (stable) version of PyLInk - only commits after 93c9b6289c
2017-03-06 16:11:04 -08:00
James Lu
7f070448b7 utils, Irc: add abstraction to warn on deprecated attribute usage (#273) 2017-03-05 00:00:26 -08:00
James Lu
e07974f803 utils: remove reference to checkAuthenticated() in NotAuthorizedError 2017-02-24 18:31:33 -08:00
James Lu
0125c544ee utils: add an IRCParser class based off argparse, modified from @IotaSpencer's code
Closes #6.
2017-02-21 21:45:43 -08:00
James Lu
75b5be5baf ServiceBot: implement global and per-service spawn_service(s) options (#403) 2017-02-18 12:54:26 -08:00
James Lu
a776aab897 utils: ignore missing services in unregisterService instead of raising an error
This is a prerequisite for the next commit (service spawn toggle options). (#403)
2017-02-18 12:54:08 -08:00
James Lu
2f968aca80 Irc: allow defaulting to private command replies (Closes #409)
Squashed commit of the following:

commit c168500235b65f833b1d7fe49ebde674159683ee
Author: James Lu <GLolol@overdrivenetworks.com>
Date:   Thu Feb 16 17:33:36 2017 -0800

    ServiceBot: default notice and private to None

    This is so that it respects the changes from the last commit.

commit f685f3ef522f7f0ee356082c3c1b8b5a4e34b211
Author: James Lu <GLolol@overdrivenetworks.com>
Date:   Thu Feb 16 15:10:33 2017 -0800

    Irc: implement a prefer_private_replies option (#409)
2017-02-16 17:41:07 -08:00
James Lu
ad873cfd7b ServiceBot: be more flexible in help formatting
* Fix text after indented docstring line breaks not showing (thanks @IotaSpencer for noticing this)
* Update formatting so that multiple consecutive newlines in a docstring are shown:
    - 2 newlines => 1 displayed new line
    - 3 newlines => 2 displayed new lines, and so on...
2017-02-15 17:06:16 -08:00
James Lu
d33eb22ca3 ServiceBot: verify that the service name is a valid nick 2017-01-21 11:59:43 -08:00
James Lu
d31d09ce7e ServiceBot: remove extra_channels argument from the constructor
This is unused and a poor thing to hardcode anyways.
2017-01-21 11:59:43 -08:00
James Lu
702ba84956 wrapArguments: add a max_args_per_line option (#253) 2017-01-11 23:09:25 -08:00
James Lu
d4b4cfb32e wrap* funcs: convert input args to a list, so that pop(0) always works 2017-01-06 22:13:27 -08:00
James Lu
12c33fcddf utils: remove incomplete example text for wrapArguments() 2017-01-02 11:08:55 -08:00
James Lu
eafec9d4ad utils: add wrapArguments() to deal with S2S message cutoffs
Ref: #253, #378
2016-12-31 23:35:27 -08:00
James Lu
95b58fc2c4 utils: abstract protocol/plugin import prefixes, and implement filtering by plugin in 'list'
Closes #369.
2016-12-16 19:25:41 -08:00
James Lu
03766b9f89 ServiceBot: implement docstring rewrapping per #307.
Closes #307.
2016-12-05 23:33:03 -08:00
James Lu
f5633329f8 utils: drop loadModuleFromFolder; it is unused since bcc84b8618 2016-12-04 23:35:16 -08:00
Ken Spencer
a1bbb4fdb9 utils: style points! WOOOO 2016-11-18 23:10:45 -08:00
Ken Spencer
fdd4135632 utils: add error() to use classes.py's irc.error() 2016-11-18 23:10:45 -08:00
James Lu
438838f81d ServiceBot: handle autojoin additions even if bots haven't spawned yet 2016-09-24 12:33:57 -07:00
James Lu
a040c3c7d2 ServiceBot: modularize join() for explicit channel joining (#326) 2016-09-23 23:43:07 -07:00
James Lu
9e7d0a50ca Revert "ServiceBot: fall back to a space in 'help' when stripped text is empty"
This reverts commit 7a3c8ab637.
2016-08-27 09:49:59 -07:00
James Lu
06cbbbb019 ServiceBot: display the NotAuthorizedError argument raw 2016-08-25 00:58:19 -07:00
James Lu
5908776a86 API CHANGE: Rename NotAuthenticatedError -> NotAuthorizedError 2016-08-25 00:43:44 -07:00
James Lu
7d2b22630d ServiceBot: display custom error messages for NotAuthenticatedError 2016-08-25 00:41:53 -07:00
James Lu
3126560fb9 ServiceBot: use newline-agnostic str.splitlines() to split up docstrings 2016-08-02 12:38:15 -07:00
James Lu
7a3c8ab637 ServiceBot: fall back to a space in 'help' when stripped text is empty
This makes sure things like newlines actually show when displaying docstrings. Closes #306.
2016-08-02 12:32:06 -07:00
James Lu
87c558537f unreal: refactor to use utils.PUIDGenerator
Closes #238.
2016-07-28 21:59:56 -07:00
James Lu
0d563eaa57 control/utils: unload the PyLink service bot on shutdown 2016-07-26 16:26:01 -07:00
James Lu
da9ab6ac90 Merge branch 'master' into devel 2016-07-23 20:57:26 -07:00
James Lu
e56c9640dc ServiceBot: remove request/remove stubs for now 2016-07-23 19:57:05 -07:00
James Lu
c6ed06ba61 utils: new splitHostmask function 2016-07-20 23:55:34 -07:00
James Lu
c52d542ed8 Initial Clientbot stub, with very rudimentary user handling (#144) 2016-07-20 23:55:34 -07:00
James Lu
ba53d63d37 ServiceBot: make sure all the defaultdict(set) instances are SEPARATE
Bit of a Python oddity here - If you initialize a class like defaultdict in a class constructor, the same instance is used for all instances of the class?

This fixes all service bots joining the same channel, when they really shouldn't be.
2016-07-07 22:56:05 -07:00
James Lu
4f26a29196 utils: unregisterService should be case insensitive 2016-07-07 22:41:39 -07:00
James Lu
bcc84b8618 core: remove references to plugins/protocols_folder (#259) 2016-07-02 23:58:21 -07:00
James Lu
d34ab6db8b ServiceBot: show an "End of help" line after featured command listing 2016-06-30 18:55:37 -07:00
James Lu
d2b5fd7b6e ServiceBot: implement short form help for featured command lists
Suggestion from @cooper.
2016-06-30 18:52:35 -07:00
James Lu
5c90cbe01f ServiceBot: always show featured commands list in private, to prevent channel floods 2016-06-30 18:37:14 -07:00
James Lu
02405c36b5 core, fantasy: redo handling of noticed and/or private replies
New behaviour for command responses in general: FANTASY commands reply in channel as PRIVMSG, while all commands sent in PM reply as private notices.

- The old irc.called_by is now irc.called_in (PLACE last command was called)
- irc.called_by is now used to store the CALLER of the last command
- notice=True/False toggle is dropped from ServiceBot.call_cmd()
- New private=True/False option added to ServiceBot.reply() and irc.reply(), which controls whether replies should be sent privately or not.
2016-06-30 18:22:45 -07:00
James Lu
0922f7cefc ServiceBot: sort featured commands list 2016-06-30 18:05:12 -07:00
James Lu
e730909a46 utils: pass featured argument to ServiceBot in add_cmd() 2016-06-30 17:57:40 -07:00
James Lu
7210161ece ServiceBot: use a shared function for showing command help 2016-06-30 17:39:53 -07:00
James Lu
a9f8b05419 ServiceBot: support service descriptions, featured commands
Closes #256. Closes #255.
2016-06-30 17:30:44 -07:00
James Lu
b90c69eead ServiceBot: actually, make extra_channels network specific 2016-06-25 14:21:13 -07:00
James Lu
ceed9346c0 ServiceBot: allow configuring extra channels that bots will join 2016-06-25 14:14:19 -07:00
James Lu
cb633cfba5 Default config file location is now pylink.yml 2016-06-21 10:59:03 -07:00
James Lu
481d70eff8 New import paths for properly installed pylinkirc 2016-06-20 18:18:54 -07:00
James Lu
fa3d230ac9 IncrementalUIDGenerator: normalize SID to strings 2016-06-16 21:55:32 -07:00
James Lu
d362063e8a ServiceBot: ignore invalid commands beginning with \x01 (CTCP) 2016-06-15 11:26:30 -07:00
James Lu
77fa3573a1 ServiceBot: remove defaults for nick and ident
This fallback is handled by coreplugin already.
2016-06-11 10:54:07 -07:00
James Lu
2877d7af4c ServiceBot.call_cmd: support notice and called_by keys 2016-05-15 11:25:47 -07:00
James Lu
5122aa8f9a utils: add unregisterService 2016-05-14 14:52:12 -07:00
James Lu
8f14e02f10 utils: return the ServiceBot instance in registerService 2016-05-14 14:23:52 -07:00
James Lu
6440922759 ServiceBot: disable request/remove commands by default
These are stubs at the moment, but still.
2016-05-14 14:15:46 -07:00
James Lu
32bc5f120b core: migrate the main client to ServiceBot (#216)
- irc.spawnMain is dropped. Clients are now spawned in the endburst loop, after protocol negotiation completes. This allows PyLink to spawn clients with hideoper, etc., closing #194.
- utils.add_cmd and irc.callCommand are now just wrappers around world.services['pylink'].add_cmd and call_cmd respectively.
- coreplugin registers the main client while it is loaded up, before any commands are added.
2016-05-14 13:29:23 -07:00
James Lu
118d76fd5a core: allow defining service bots with custom nicks/idents 2016-05-14 12:52:32 -07:00
James Lu
5b3059c85d ServiceBot: fill in 'help' and 'list' commands (#216) 2016-05-14 12:22:00 -07:00
James Lu
924172291f ServiceBot: work out basic command handling
This copies callCommand from the IRC object into ServiceBot.call_cmd. The former will be removed once the main PyLink client is migrated to a service bot.
2016-05-14 10:17:40 -07:00
James Lu
0c7faed213 Move NotAuthenticatedError class back into utils
This is needed because ServiceBot exists in utils, and utils cannot import classes without a bad import loop happening.
2016-05-14 10:05:18 -07:00
James Lu
7d11f8c7e0 Begin work on service bot abstraction (#216)
- State-keeping is done by coreplugin
- utils.registerService() introduced
- new PYLINK_NEW_SERVICE hook introduced
2016-05-14 09:55:46 -07:00
James Lu
beae4eea9e core: rename utils.fullVersion -> irc.version (#199) 2016-04-30 17:00:28 -07:00
James Lu
3bb1208e74 core: move toLower to Irc (#199) 2016-04-30 16:57:38 -07:00
James Lu
2fe2e9c8c4 core: move isOper, checkAuthenticated to Irc (#199) 2016-04-30 16:54:11 -07:00
James Lu
78f8a2fc8d core: move isManipulatableClient, getHostmask to Irc 2016-04-30 16:44:37 -07:00
James Lu
064cb9b6aa core: move reverseModes, joinModes into Irc 2016-04-30 16:33:46 -07:00
James Lu
f1351bb3f5 utils: introduce deprecation warnings for applyModes and parseModes 2016-04-24 21:44:34 -07:00
James Lu
84822fb1d6 Move applyModes, parseModes into Irc, suppressing deprecation warnings for now (#199) 2016-04-24 21:44:27 -07:00
James Lu
7f46e1c35c Separate KeyedDefaultdict into new structures module (#199) 2016-04-24 21:11:36 -07:00
James Lu
2c60aa6395 Separate UID/SID generators into various protocol modules (#199) 2016-04-24 21:08:07 -07:00
James Lu
dc1d9602e9 utils: add a simple P10 UID generator (#87)
Reference: https://github.com/evilnet/nefarious2/blob/a29b631/doc/p10.txt#L85-L92
2016-04-05 18:45:00 -07:00
James Lu
e2edc68fe8 utils: check explicitly for "pos is None", as 0 is a falsey value too
Without this, the UID generator would refuse to change the left-most character of the UID, as it is position 0.
2016-04-05 18:44:00 -07:00
James Lu
cb8ea473df utils: modularize UID generators 2016-04-05 18:05:52 -07:00
James Lu
305db9f754 utils: also don't crash in applyModes for bad mode targets 2016-03-26 18:14:53 -07:00
James Lu
e70dfb0811 Merge branch 'master' into devel 2016-03-26 17:58:18 -07:00
James Lu
2169a9be28 utils: actually abort when mode target is invalid 2016-03-26 17:58:03 -07:00
James Lu
00552a41a7 Move detailed version string generation to utils
New function: utils.fullVersion(irc)
2016-03-26 11:33:47 -07:00
James Lu
03b53aee59 Merge branch 'staging' into devel 2016-03-25 15:03:05 -07:00
James Lu
0fd093644c utils: don't crash when mode target is invalid 2016-03-23 18:04:12 -07:00
James Lu
d84cfbcda1 utils: simplify prefix modes handling in applyModes 2016-03-19 17:47:23 -07:00
James Lu
8135f3a735 core: Depluralize prefixmodes mappings (#168)
This is an API breaking change. I really don't know why I made these keys plural to start, since it only made things more complicated. Prefix modes are not pluralized in the list of supported modes of each IRCd.
2016-03-19 17:25:04 -07:00
James Lu
544d6e1041 utils: add KeyedDefaultdict
This is a subclass of defaultdict allowing the key to be passed to the default factory.
2016-03-19 17:01:16 -07:00
James Lu
14388d932f utils.getHostmask: add option to return IP address 2016-03-05 09:52:00 -08:00
James Lu
0430e1dae7 utils.getHostmask: option to return hostmask with real host, use placeholders w/o spaces in them 2015-12-31 18:09:52 -08:00
James Lu
eac934c237 classes: sort code, move nickToUid, clientToServer, isInternalClient, isInternalServer into the Irc class
The following BREAKING changes are made:
utils.nickToUid(irc, nick) -> irc.nickToUid(nick)
utils.isInternalClient(irc, uid) -> irc.isInternalClient(uid)
utils.isInternalServer(irc, uid) -> irc.isInternalServer(uid)
utils.clientToServer(irc, uid) -> utils.getServer(uid)
2015-12-31 17:28:47 -08:00
James Lu
11adee9d78 Yet another documentation refresh (#113) 2015-12-26 14:45:28 -08:00
James Lu
9a81a2ba1f Rename utils.getProtoModule => utils.getProtocolModule 2015-12-24 17:33:49 -08:00
James Lu
31c47b50f3 utils: fix irc.users changing size during lookup 2015-12-11 18:43:58 -08:00
James Lu
e4fb64aeba Document more parts of the core - comments are cool right 2015-12-06 17:40:13 -08:00
James Lu
561af2e037 utils/relay: add and use getDatabaseName to fetch an instance-specific DB name 2015-12-06 17:13:47 -08:00
James Lu
197532c1be core: Replace imp (deprecated) with importlib, reword some docs & remove unneeded imports 2015-11-22 20:14:47 -08:00
James Lu
b3ab604b88 utils: return the bound function in add_cmd/add_hook
TODO: allow utils.add_cmd/add_hook to be called as a decorator WITH a name argument
2015-10-23 18:47:11 -07:00
James Lu
c0eab152e4 utils: fix error handling in parseModes 2015-10-08 20:59:31 -07:00
James Lu
b8fe622cc8 utils: don't allow hostmasks/banmasks to have # in them 2015-10-08 17:25:49 -07:00