63 Commits

Author SHA1 Message Date
Em Barry
745a1dc68a
Convert chk_decision (#317)
Convert chk_decision, chk_nightdone, transition_day, transition_night, doomsayer, mayor, and convert+split shamans in three files with a shared helper. Fixes and updates for the User containers, and some other tweaks and fixes.
2018-04-23 13:25:38 -04:00
Em Barry
42424e49df Add support for CHGHOST (#318)
Add proper support for CHGHOST, and also get rid of some misguided assumptions in the hooks.
2018-04-18 11:16:01 -07:00
Vgr E. Barry
ae4c342bd3 Revert service storing and properly fix /mode handling issue 2018-04-13 18:02:37 -04:00
Vgr E. Barry
33051ae617 Preemptively store services in a dummy channel for get() purposes 2018-04-13 17:31:47 -04:00
skizzerz
f988293f42 rm extraneous nonlocals 2018-01-10 12:30:03 -07:00
skizzerz
916d476ca5 Fix SASL support for ircds which don't advertise SASL types in CAP 2018-01-10 12:14:02 -07:00
skizzerz
9190a4c859 Rework TLS validation a bit and support SASL EXTERNAL
- Move the config comments to botconfig.py.example where they will be more useful,
  and move the bits in settings.py near the other IRC-related settings.
- Removed support for hash types that aren't SHA-256 as we perform all the hashing on
  our end (doesn't matter what the server does or does not support), and this greatly
  simplifies the code while leaving things secure enough.
- Hardcode a default cipher suite according to mozilla modern standards, as the
  builtin ciphersuite in python may be less secure for older python versions.
- Add support for EXTERNAL auth in SASL, if a client certificate is provided. If this
  fails, it will fall back to PLAIN auth (to account for the case where a cert is added
  to the bot, but has not yet been added to NickServ, so that the bot can connect and add
  it to NickServ via !fsend)
- Redact passwords from console/log output so that asking people to pastebin their
  --verbose output when reporting issues in #lykos is less fraught with peril.
2018-01-10 12:09:10 -07:00
skizzerz
f4876d254e Convert some things to new command API+users
MessageDispatcher, sleepy mode, warnings, and the latency command,
to be exact. Sleepy also benefits from some code deduplication in
addition to now operating on users.

The warnings code could use a more comprehensive overhaul too, but
that's going to be harder to achieve.
2018-01-09 16:06:40 -07:00
Vgr E. Barry
08a81fbc09 Properly handle CAP LS lines with name=value items in them 2018-01-05 14:23:58 -05:00
skizzerz
b677400ce4 General cleanup
- Expand skel.py to be more useful
- Remove circular dependency from utilities.py. It *CANNOT* globally
  import users.
- Remove unused functions from utilities.py and make some others proxy
  through to user-aware functions to ensure functionality stays the
  same.
- Remove duplicate event listener.
- Clarify some comments about stats.
2017-12-29 16:10:32 -06:00
jacob1
50f77439fb fix dead vengeful ghost being unable to use any commands 2017-11-13 00:22:33 -05:00
Vgr E. Barry
d04891346a More things 2017-09-18 16:45:33 -04:00
Vgr E. Barry
370b2c6ed2 Some function and event updates 2017-08-23 22:06:43 -04:00
Ryan Schmidt
1cc38e54b2 Make potato an alias for villager (#290)
Also allow prefixing commands by their role name to remove ambiguity
should a person be multiple roles. For example, "seer see foo" and
"augur see foo" will now work if a person is both seer and augur
(whereas normal see foo would be ambiguous). A player will be directed
to use the unambiguous prefixed version if we detect that a role command
will fire multiple times for them (note: coming soon).

For sanity reasons, these role prefixes are implemented as exclusive
commands, meaning no other commands or command aliases may use the same
name. Clone needs to be special-cased in this regard, as clone is both a
role name and a command name.
2017-03-24 16:31:08 -04:00
nyuszika7h
1c5761ce26 Make the ping thread daemonized to allow the bot to quit 2017-01-19 21:22:59 +01:00
Vgr E. Barry
ad7e0f11ac Ignore messages received before the bot is fully set up 2017-01-17 12:52:27 -05:00
nyuszika7h
bde640c9ae Don't attempt to identify with no password set
Some servers disconnect the client if PASS fails, so the bot will fail
to connect unless SERVER_PASS is also explicitly set to None.
2017-01-16 12:40:14 +01:00
nyuszika7h
a6e4d2b3c1 Fix ping handling
Don't start a new timer every time someone calls !latency, and make it
work even if automatic pinging is disabled. Also, moved the command to
handler.py per @Vgr255's suggestion.
2017-01-06 17:07:42 +01:00
nyuszika7h
6f7e4398dd Simplify latency checking code
Since we send the timestamp of the request with the ping and the server
will send it back, there is no need to store it.
2017-01-06 16:20:40 +01:00
nyuszika7h
a6e3c0a720 Periodically ping server to detect disconnection
In some cases, disconnection from the server can be unclean and won't be
noticed until the bot tries to send a message, which may never happen if
it did not disconnect during the game. To solve this problem, it will
now ping the server every 2 minutes by default, which will result in
a broken pipe error if the connection is dead. This won't be able to
detect netsplits where the server the bot is on stays online, because
those are impossible to correctly detect in every case.

This commit also adds a !latency command so that users can verify if the
bot is lagging.
2017-01-06 15:52:26 +01:00
nyuszika7h
a3fd532b3a Fix UnboundLocalError for regain/release 2016-12-16 11:38:07 +01:00
Vgr E. Barry
e8338d1ef6 Add the new command API + converted commands
Converted commands mostly use some backwards-compatibility hack. Please don't mind it, I'll eventually get to it.
2016-11-28 20:19:48 -05:00
skizzerz
1f7b5ee6a3 Break infinite regain/release loops redux 2016-11-20 21:44:40 -06:00
skizzerz
11d626ab25 Revert old_api cmd change
Causing way too many bugs, need to use a more sane method of breaking
the cmd API, and only do so when it's actually ready to go. My
personal preference is to make the new API use @command instead of @cmd.

This reverts commits c90d35e6c0a9ba96692e9d73bbe27efca405d542 and 5f5966a8b49e5214c82d806ac43a2553754fdee6.
2016-11-20 21:33:36 -06:00
skizzerz
24ae5c1e39 Kill USE_NICKSERV_GHOST, default more things in settings.py
Whether or not GHOST is used now depends on if NICKSERV_RELEASE_COMMAND
or NICKSERV_REGAIN_COMMAND are empty. Also, we do not try to go into an
infinite loop should the command we use fail to work, and instead just
run with a "wrong" nick.

Not tested at all, so blame ilbelkyr when things inevitably don't work
with it (and while you're blaming him, get him to fix the ASM website).
2016-11-20 12:36:31 -06:00
Emanuel Barry
5f5966a8b4 Add a transition method for the old->new interface (#272)
* Add a transition method for the old->new interface

* Modify direct calls to cmd to explicitly use the old API
2016-11-19 17:47:54 +01:00
Vgr E. Barry
1766f54b21 Properly handle the option to use ghost or release 2016-11-18 21:14:15 -05:00
Vgr E. Barry
885889495a Properly handle the bot's nick being already in use 2016-11-16 16:18:37 -05:00
Vgr E. Barry
e161325d01 Remove 'channels' from the user interface
We don't use it, as the only places where we'd need to, it's only one channel, and the surrounding code needs to add the user to the channel and vice-versa, so that's pretty pointless.
2016-11-10 10:44:38 -05:00
Vgr E. Barry
52b28b4317 Fix case-sensitiveness on weird IRCds 2016-11-08 17:04:32 -05:00
Vgr E. Barry
d090e573b7 Greatly improve channel handling
This also does some more bits of rudimentary user handling, but most of it still remains to be done.

Note: This adds DEV_PREFIX to botconfig and LOG_PREFIX to settings (var), make sure to properly update your bot!
2016-11-02 22:31:54 -04:00
Vgr E. Barry
5c9b13ce87 Improve NOTICE handling
The `notice` parameter is now keyword-only, and the handler now uses `functools.partial` instead of a lambda function.
2016-10-31 20:59:52 -04:00
jacob1
ead74e0fe5 log !fwarn add/set/del to LOG_CHANNEL, if set 2016-08-17 23:55:22 -04:00
Vgr E. Barry
6460eb6804 Define methods in IRCClient instead of using a decorator
Mypy doesn't like it.
2016-08-13 12:33:20 -04:00
skizzerz
1b7b2f6799 Make discrimination based on case ilegel
All hostmask and account comparisons are now case-insensitive (nicks
still aren't, related to #217 -- changing nick sensitivity would break
everything in numerous places).

Also, refactor some things into other files where it makes sense to do
so, because putting unrelated things into the same commit is fun.
2016-07-27 17:03:34 -05:00
nyuszika7h
9ea9a1a317 Fix modelines in other files 2016-05-11 16:09:19 +02:00
Ryan Schmidt
fe451962cd Fix spurious error when ending night as shaman and dying.
An artifact of how we run commands means that we try to run the rest of
the "give" command handlers even after the first (shaman) one ended night.
As such, check the phase and if it's different, stop trying to execute
command handlers.

This has a small race condition where the error this fixes can happen
anyway, but since it's purely a visual error I think that's fine. Better
than happening all of the time, at least.
2016-05-10 15:37:57 -07:00
nyuszika7h
c6a5cea715 Log connection, end of MOTD and joining channels in normal mode 2015-11-27 17:37:04 +01:00
Vgr E. Barry
b28d4bf6e3 Properly fix the error handler 2015-11-04 12:41:47 -05:00
jacob1
e77ad447ef fixes to nightmares 2015-10-30 18:03:43 -04:00
jacob1
0ac28c290b fix bot not being able to connect to some strange networks 2015-10-04 00:14:30 -04:00
nyuszika7h
aaddfb5a93 Fix never reached condition 2015-09-09 18:07:34 +02:00
nyuszika7h
8a90145474 Case-insensitively compare the bot's nick when checking for PMs
Closes #161.
2015-09-06 11:46:49 +02:00
Emanuel Barry
f55492e6c8 Unconditionally print traceback
In debug mode traceback could go unprinted.
2015-08-27 18:17:45 -04:00
Emanuel Barry
b3f30bbd91 Improve error handler
Now it will only pastebin the error when it has finished gathering it
all.
2015-08-27 10:02:56 -04:00
Vgr E.Barry
38b7ef81e2 Add proper error handling. Closes #151
All exceptions, if not caught, are unconditionally sent to `sys.stderr`.
We only need to use our own custom class with some modifications and we
can intercept all errors, even those in threads (which #151 was about).
The only real downside from this practice is that `cli` is not
accessible to us when the errors happen, so I used a hack to set it on
an instance variable. If anyone can find a better solution, please step
forward. For the time being, this will have to do.

If for some obscure reason this class breaks, `sys.__stderr__` holds the
original `sys.stderr`
2015-08-06 12:29:47 -04:00
Vgr E.Barry
7c9b5ce51b Fix decorators 2015-07-31 13:29:26 -04:00
skizzerz
e27fd8c1fa Fix connect hooks
Apparently having multiple hooks on the same thing is just horribly
broken, even though we do it in other places. This only fixes the issue
on connecting as that one is the most severe, but the other cases will
need to be fixed as well (or the underlying issue preventing it from
working needs to be fixed).
2015-07-29 03:14:10 -05:00
skizzerz
dbb80a940e Fix issues related to undernet (and in general)
- Now possible to use the bot without it having a registered account by
  blanking NICKSERV_IDENTIFY_COMMAND
- Now possible to configure who ChanServ is as well as the command it
  uses to op up in channel (blank to prevent it from auto-opping).
  Example configuration provided for undernet
- Properly autojoin channels even if there isn't an MOTD
2015-07-28 22:35:47 -05:00
nyuszika7h
32ab792e2f Use the specified username for NickServ identify 2015-07-27 14:19:46 +02:00