Commit Graph

1071 Commits

Author SHA1 Message Date
skizzerz
740d14ef72 Experimental stats: intelligently determine if traitor could have died
If it is impossible for other (non-wolf) roles to have killed at night,
we do not deduct from the traitor count. This logic isn't perfect yet,
but should cover the majority of cases.
2017-01-16 16:38:51 -06: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
Vgr E. Barry
cef59bce73 Fix small variable error 2017-01-15 10:03:11 -05:00
Vgr E. Barry
693ebf3546 Fix some oversights 2017-01-13 16:28:09 -05:00
Vgr E. Barry
d2211de510 Update deadchat handling 2017-01-13 16:17:40 -05:00
Vgr E. Barry
fea04471ca Properly lowercase host everywhere 2017-01-13 16:17:03 -05:00
Vgr E. Barry
a0550f922b Allow passing a list or tuple to IRCContext.queue_message 2017-01-13 16:15:20 -05:00
Vgr E. Barry
fb7bf56579 Fix proper lowercasing, take 2 2017-01-13 12:13:32 -05:00
Vgr E. Barry
2cd410ace8 Fix lowercasing a hostname to not use IRC lowercasing 2017-01-13 12:05:16 -05:00
Vgr E. Barry
4f36b189ff Update pingif timer handler 2017-01-13 12:00:09 -05:00
Vgr E. Barry
96c36a13b6 Fix lowercasing a BotUser instance 2017-01-13 11:59:47 -05:00
Vgr E. Barry
52f6b9238a Fix fspectate 2017-01-13 11:59:24 -05:00
Vgr E. Barry
a620860cc5 Update who_end event parameter 2017-01-13 11:57:16 -05:00
Vgr E. Barry
0ca9e8cbdb Update the pingif command 2017-01-12 15:29:55 -05:00
Vgr E. Barry
582523bda5 Update refreshdb and ping commands 2017-01-12 15:29:34 -05:00
Vgr E. Barry
abf663706d Update fsync and related functions 2017-01-12 15:28:58 -05:00
Vgr E. Barry
889408a7bb Remove redundant lines 2017-01-12 14:13:05 -05:00
Vgr E. Barry
b3552574d5 Update database on simple and notice toggle 2017-01-12 14:02:17 -05:00
Vgr E. Barry
ce8babec56 Update the notice toggle command 2017-01-12 13:57:24 -05:00
Vgr E. Barry
eb5a54474e Update the simple toggle command 2017-01-12 13:57:14 -05:00
Vgr E. Barry
f941f23e91 Update some docstrings in users.py 2017-01-12 13:55:07 -05:00
Vgr E. Barry
fe692dd74e Update fdie and frestart to use the new command API 2017-01-12 12:46:05 -05:00
Vgr E. Barry
1b695b4849 Use the new IRCContext.send API instead of break_long_message 2017-01-12 12:45:16 -05:00
Vgr E. Barry
4a02943a6e Use context directly for mode change 2017-01-12 12:44:34 -05:00
Vgr E. Barry
81c96f4a56 Tweak hooks.quit 2017-01-12 12:43:41 -05:00
Vgr E. Barry
87df9e1440 Add a client attribute to MessageDispatcher 2017-01-12 12:43:18 -05:00
Vgr E. Barry
16022599e5 Use __class__ cell for channel comparisons 2017-01-12 12:42:46 -05:00
Vgr E. Barry
420d67250f Fix setting channel mode to None 2017-01-11 23:08:45 -05:00
Vgr E. Barry
fb6aa40170 Please stand away from water sources when short-circuiting 2017-01-11 22:54:19 -05:00
Vgr E. Barry
4bedfb0848 Fix unbound variable in sighandler 2017-01-07 11:28:05 -05:00
Ryan Schmidt
b1271ecbe0 Merge pull request #277 from lykoss/part-quit-hooks
Improve user part/quit/nick hooks
2017-01-06 10:17:28 -07: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
06c60dfdc3 Fix circular import
The strange thing is that it was working on my test instance.
Probably because Python 3.6 changed something regarding that.
2017-01-06 15:58:53 +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
Vgr E. Barry
d78f0e5179 Fix realname being a space breaking handling 2017-01-01 11:01:33 -05:00
Vgr E. Barry
e0f8f172d6 Update part/quit/kick/nick hooks 2016-12-19 13:29:20 -05:00
Vgr E. Barry
53cd5dc616 Add a users.complete_match function, taking and returning Users 2016-12-19 13:29:02 -05:00
Vgr E. Barry
081f909260 Use proper __class__ cell for super 2016-12-19 13:10:06 -05:00
Vgr E. Barry
e7eabba791 More easily create fake users 2016-12-19 13:09:57 -05:00
Vgr E. Barry
85f8f9717a Change variable name to be more informative 2016-12-19 13:09:47 -05:00
Vgr E. Barry
b6738f2216 Better handle channel key 2016-12-19 13:09:34 -05:00
Vgr E. Barry
898a7107ca Allow passing contexts to Channel.mode 2016-12-19 13:09:23 -05:00
Vgr E. Barry
9014d5c35c Make comparing contexts easier 2016-12-19 13:09:12 -05:00
Vgr E. Barry
59e7c13a0b Move equals from users to context 2016-12-19 13:08:18 -05:00
Vgr E. Barry
63d908a61a Properly handle channel casing 2016-12-19 13:08:07 -05:00
nyuszika7h
a3fd532b3a Fix UnboundLocalError for regain/release 2016-12-16 11:38:07 +01:00
Vgr E. Barry
33563da1eb Fix users.get(..., allow_multiple=True) to always return a list 2016-12-14 20:04:36 -05:00
skizzerz
6bf12520f1 Fix day timeout causing game to end twice 2016-12-14 10:23:00 -06:00
nyuszika7h
144b01cfed !restart already fixed, small change for consistency 2016-12-11 10:27:39 +01:00
nyuszika7h
218366cbd8 !die: Fix first word of message being cut off in debug mode 2016-12-11 10:25:14 +01:00
Vgr E. Barry
06486e14bd Fix fsay/fact broken for non-existent users 2016-12-11 01:33:14 -05:00
Vgr E. Barry
dff024e5e4 Allow contexts to be used directly in str.format() calls 2016-12-09 10:56:34 -05:00
Vgr E. Barry
e1be940f24 Fix !join erroring out 2016-12-09 10:54:16 -05:00
jacob1
2c5e108751 fix error on !join when ACCOUNTS_ONLY is set 2016-12-09 07:56:40 -05:00
Ryan Schmidt
9f4b1a243d Merge pull request #274 from lykoss/cmd-old-api
Add a backwards-compatibility handler for commands
2016-12-08 16:35:19 -07:00
skizzerz
47339618f8 Remove part/fpart command
There is no reason for this to be a command. It has no analogue outside
of fsend, in which case you can just fsend a raw PART if needed as well.
2016-12-08 17:23:15 -06:00
Vgr E. Barry
bb8548ccdf Right. 2016-12-06 08:40:12 -05:00
nyuszika7h
3d5aa8c8e3 Fix message name 2016-12-05 14:06:22 +01:00
nyuszika7h
b2104e4d36 Respect LOG_PREFIX for !fwarn add/set 2016-12-01 23:21:01 +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
nyuszika7h
da502fa34c Require a minimum of 6 players for charming
In 5-player charming games, it is possible to get into a situation where
it's impossible for the village to win - if all players except for the
wolf are charmed, lynching the wolf results in the piper winning, and
lynching the piper results in the wolf winning.
2016-11-25 14:23:16 +01:00
Vgr E. Barry
c26c7887bc Add a hook for account changes 2016-11-24 17:05:08 -05:00
Vgr E. Barry
5f50096d08 Delay error in users.get until after the end of the loop
This was originally done so that we wouldn't need to iterate through the (presumably large) set of users. However, when this raises, we have no idea which users actually match the criterias. By waiting until after, the traceback will actually print off the list of all potential users.
2016-11-24 16:29:58 -05:00
nyuszika7h
21b8ffa342 Fix denying commands with warnings 2016-11-24 16:17:53 +01:00
skizzerz
08652301c2 Properly delay night properly in villagergame, all proper-like now 2016-11-23 16:27:37 -06:00
skizzerz
a01f8860d0 Delay night properly in villagergame 2016-11-23 16:26:06 -06:00
nyuszika7h
ed7d3eda6a Add a random delay to night in villagergame 2016-11-23 19:34:41 +01:00
jacob1
bb99493ae8 fix protections not carrying over after nick change 2016-11-23 11:53:45 -05:00
Vgr E. Barry
27b0c9578d Move static methods out of the IRCContext class 2016-11-22 07:42:07 -05:00
Vgr E. Barry
423f7e352c Fix IRCContext.send_messages 2016-11-22 07:40:29 -05:00
Vgr E. Barry
ea3acbfb2a Allow implicit replacement of users without a ident and a host
This takes a different code path because of slightly different conditions; in the first case, the ident and host are both known, and so the instance is hashable. Being hashable, it can be checked for set containment, and exactly one instance in that set will be equal (since the hash is based off of the ident and host, and the comparisons check for all non-None attributes, two instances cannot possibly be equal while having a different hash).

In the second case (the new one), however, at least the ident or the host is missing, and so the hash cannot be calculated. This means that two instances may compare equal and hash to different values (since only non-None attributes are compared), so we need to run through the entire set no matter what to make sure that one - and only one - instance in that set compares equal with the new one. We can't know in advance whether or not there is an instance that compares equal to the new one in that set, nor can we know if there are multiple instances that are going to compare equal.

The two code paths are separated so that the difference in functionality is obvious (and this commit description, as well as the comment in the code, should help with that), and that the distinction remains clear.
2016-11-21 21:44:34 -05:00
Vgr E. Barry
ea51642240 Allow users.get(..., allow_multiple=True) to return an empty list 2016-11-21 21:12:27 -05:00
Vgr E. Barry
d590e7b727 Fix servers setting modes and !fsync breaking the bot 2016-11-21 10:29:14 -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 c90d35e6c0 and 5f5966a8b4.
2016-11-20 21:33:36 -06:00
jacob1
c90d35e6c0 add old_api=True to sleepy commands, default it to true 2016-11-20 22:30:13 -05:00
skizzerz
ed2576ef7e Remove debug printouts 2016-11-20 12:49:21 -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
skizzerz
73fb0c65c9 Fix coin/pony chances 2016-11-20 12:33:39 -06:00
Vgr E. Barry
e922bb220e Move the message queuing to IRCContext 2016-11-20 08:25:45 -05:00
Vgr E. Barry
6d9017a4bd Improve context creation and lowercasing 2016-11-20 08:24:50 -05: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
nyuszika7h
313d33f1a2 Display full help text on bare "!fwarn" and "!fwarn help"
It was listing the warnings on a bare "!fwarn" because re.split()
returned an array containing one element, the empty string. And it's not
really helpful to show just the syntax for the help subcommand in
"!fwarn help", because it already does that in the normal help message,
and also shows the available subcommands.
2016-11-19 17:10:50 +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
9a71b34488 Improve message sending to properly split on the end of lines 2016-11-18 17:27:33 -05:00
Vgr E. Barry
302b69c263 Probably channel life events
Blame @skizzerz for making me want to do a very bad pun as this commit summary.
2016-11-18 16:50:27 -05:00
Vgr E. Barry
112c908596 Allow an arbitrary number of arguments to IRCContext.send 2016-11-17 10:10:53 -05:00
Vgr E. Barry
dbb8a1fc82 Fix devoicing and unquieting on connect
This wasn't working before, because the mode checking was wrong. Furthermore, there may have been some race conditions; this was mitigated by an earlier commit, which allowed delaying some channel handling operations.
2016-11-17 10:06:37 -05:00
Vgr E. Barry
c6864dd7e7 Fix wrong hook name
For some reason, the end of a quiet listing has a different hook name.
2016-11-17 10:03:04 -05:00
Vgr E. Barry
074548813f Delay some channel handling operations
Specifically, the mode handling and the end of list modes are delayed until the end of the WHO reply from the server. When the end of the WHO reply is received, all queued operations on the channel, if any, are triggered at once in the form of relevant events.
2016-11-17 10:01:25 -05:00
jacob1
b180f99051 add 0-point warnings, these need to be acknowledged but give no automatic sanctions 2016-11-16 23:56:55 -05:00
jacob1
017a98608c Fix lowercasing issue in !fstasis, fix "host has access" message in !fflags 2016-11-16 23:42:23 -05:00
skizzerz
ae5b39c36f Split traitor
As part of this, adjust team and accurate stats to no longer hide any
information. For team stats in particular, it was very misleading to
list traitor as villager, because it gives the village the impression
they have more time than they actually do (i.e. 2 wolfteam 5 vilteam
actually means 3 wolfteam 4 vilteam but that is not obvious). As team
stats were changed, team reveal was also changed to disregard hidden
traitor, so that the two can't be correlated to pick out if traitor died
(if traitor was revealed as vilteam but stats decremented wolfteam, that
would guarantee that traitor died).

Also commit groundwork for the stats rewrite, hidden behind an
"experimental" stats type (so it is not on by default). It is still very
WIP, many things do not yet work with it.
2016-11-16 22:19:54 +01:00
Vgr E. Barry
885889495a Properly handle the bot's nick being already in use 2016-11-16 16:18:37 -05:00
nyuszika7h
d62b9db896 Also abort if 'git status' fails 2016-11-16 15:04:05 +01:00
nyuszika7h
82d6760c5a !update: Don't restart the bot if already up-to-date 2016-11-16 14:59:29 +01:00
Vgr E. Barry
abd2dd149d Allow handle_error to decorate its instances 2016-11-16 08:20:02 -05:00
nyuszika7h
be2d33dbe6 Make traceback pastes not expire automatically
Since we have the UUID now, we can delete them at any time if needed,
they don't have to expire automatically, which can be annoying when
trying to look up an old error (although it's also in errors.log).
2016-11-16 14:05:18 +01:00
Vgr E. Barry
3f806620e4 _ 2016-11-15 20:38:29 -05:00
Vgr E. Barry
3e61e9ec6a Beauty is in the eye of the tiger 2016-11-15 20:37:40 -05:00
Vgr E. Barry
360204bf43 Massively improve user handling
This changes how users are handled, making it less likely to encounter duplicate users; in normal circumstances, duplicates shouldn't happen.
2016-11-15 19:54:42 -05:00
jacob1
01924504fe Fix day never ending when the only votes are on the bot at day timeout 2016-11-14 23:34:09 -05:00
nyuszika7h
2c3aafc101 Improvements to !rules
* RULES is now not defined in settings.py, only in botconfig.py.

* If there are no rules specified, a default message is shown
  instructing users to configure it.

* The "#CHANNEL channel rules: " prefix is now automatically prepended
  (skipped if the string already contains that,
  for backwards-compatibility).

* The prefix and the no-rules message can be customized
  as they are in messages.py now.
2016-11-13 11:54:48 +01:00
Trigonoculus
629fe51fd7 Make rules string unconfigured by default (#269)
The old link was outdated anyway, and other networks may not use the same rules as freenode, so it should be just configured in botconfig.py like it always could.
2016-11-13 11:32:30 +01:00
skizzerz
64e6a90921 *hic*
Make doctor immunize work against doomsayer sickness and pestilence
totem
2016-11-12 23:46:45 -06: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
Ryan Schmidt
8039b5e2a1 Merge pull request #266 from lykoss/werecrow_kill
Allow werecrow to both observe and kill at the same time
2016-11-07 23:13:10 -07:00
jacob1
0c8afe4f64 Fix db error when adding a tempban sanction on a player that already has one, fixes #245
Can happen when doing it manually, or when adding a warning after it expired but before expire_tempbans() is called
2016-11-07 21:10:18 -05:00
jacob1
cd118dbabe allow werecrow to both observe and kill at the same time 2016-11-07 20:52:58 -05:00
Vgr E. Barry
d6f2882741 Fix syntax error
Turns out that's 3.5+
2016-11-06 22:18:17 -05:00
Vgr E. Barry
fb2ece45e6 Clean up some of doomsayer's code 2016-11-06 21:54:29 -05:00
Vgr E. Barry
7c753b2810 Improve the error handler
Also, thanks to @nyuszika7h for the uuid idea. I took his early draft and implemented it properly as part of the refactoring I did.
2016-11-06 21:43:01 -05:00
Vgr E. Barry
a39ded6053 Improve handling of fake contexts 2016-11-06 17:27:09 -05:00
Vgr E. Barry
61bca595c5 Fix small oversight 2016-11-06 17:26:46 -05:00
jacob1
3db042967d fix adding/removing tempbans to hostmasks 2016-11-05 11:40:16 -04:00
jacob1
fde2ce94db fix bot pinging fake players after !fstop 2016-11-05 11:13:35 -04:00
jacob1
5d0021de7d fix possible error when setting flags on users 2016-11-05 00:21:15 -04:00
nyuszika7h
e4f696abe6 Fix villagergame appearing above 9p
In join phase, var.PLAYERS is empty, so var.ALL_PLAYERS needs to be
checked instead.

(While I'm at it, changed it to <= 9 rather than < 10, just for
consistency with the rest of the code.)

Fixes #263.
2016-11-04 21:45:29 +01:00
jacob1
6293b61d83 fix error when villagergame kills someone with a retribution totem, fixes #224 2016-11-03 23:26:30 -04:00
jacob1
f101c62af8 Fix !fflags +j overwriting flags when account name is uppercase, fixes #254
Also allow setting flags on players that haven't played any games
2016-11-03 22:06:13 -04:00
nyuszika7h
136e41a14c Add newline for readability 2016-11-04 00:06:51 +01:00
skizzerz
341cce6a8f Split mayor
Also adjust revealing totem so that it always fires after mayor, in case
someone has both. Before it would depend on the order the files were
imported, which could lead to oddities down the road.

This fixes #256
2016-11-03 16:29:15 -05:00
Vgr E. Barry
2244ed4370 Fix wrong function calls in user functions 2016-11-03 12:04:26 -04:00
Vgr E. Barry
a6424605ad Fix error when bot restarting and players were joined
AKA name error
2016-11-03 11:35:17 -04:00
Vgr E. Barry
cce2797e7b Fix name 2016-11-03 11:29:03 -04:00
Vgr E. Barry
851cebdbd7 Remove test function
Oops.
2016-11-03 11:26:39 -04:00
Vgr E. Barry
62abf6dae8 Fix small issues with fake nicks and channels 2016-11-02 23:35:13 -04: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
49208db148 Make backwards-compatible users.add return the new "user" 2016-11-02 16:15:16 -04:00
Vgr E. Barry
04e7f952d3 Improve error handler 2016-11-02 15:18:32 -04:00
Vgr E. Barry
0120836669 Don't bother using a channel state in __del__
If the channel is being deleted, we don't need to care about the state. Furthermore, if the channel is being deleted as Python is shutting down, _States will have been deleted (or set to None), so we can't access it. Rather than trying to work around the garbage collection, we just set it to None and call it a day.
2016-11-02 14:52:30 -04:00
Vgr E. Barry
b4fc7ac82d Remove leftover parameter 2016-11-02 14:34:33 -04:00
Vgr E. Barry
736d1219ed Fix oversight in account handling 2016-11-01 23:04:47 -04:00
nyuszika7h
6932c42574 Fix traceback syntax highlighting
Additional text at the end (local variables) has a red border for each
line with py3tb, but not with pytb.
2016-11-01 23:16:55 +01:00
nyuszika7h
dccfd9de38 Require "!leave -force" to quit during a game 2016-11-01 15:34:49 +01:00
Vgr E. Barry
b67043d25f Small tweaks 2016-10-31 22:25:20 -04:00
Vgr E. Barry
3de4469809 Comment out yet-to-be-tested hooks 2016-10-31 22:23:42 -04:00
Vgr E. Barry
fe141b288f Allow specifying a prefix (e.g. for channels) for context.send() 2016-10-31 22:22:48 -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
Vgr E. Barry
12eab068be Change the user handling calls in wolfgame.py 2016-10-31 20:44:10 -04:00
Vgr E. Barry
795caa83fe Forward fixes for the new interface 2016-10-31 17:57:48 -04:00
Ryan Schmidt
7e856859cb Merge pull request #250 from lykoss/irc-hooks
Add a new hooks.py file
2016-10-31 10:13:19 -07:00
jacob1
0a7752fd15 newline changes in error logger
local variables were right next to the next traceback in errors.log even though the belonged to the previous one
2016-10-30 23:02:50 -04:00
Vgr E. Barry
d602a33efd Update handle_error to be more useful
Now, local variables from the innermost frame (i.e. where the error was raised) are printed with the traceback, and the latter includes all of the call stack (instead of just up to the innermost error handler).
2016-10-30 22:34:46 -04:00
Vgr E. Barry
a2257ce692 Fix pastebin_tb to actually use the passed traceback 2016-10-30 22:32:54 -04:00
nyuszika7h
c968e1192a Even better exception printing, like in tracebacks 2016-10-30 20:12:15 +01:00
Vgr E. Barry
e5f922d548 Improve exception printing through !eval and !exec 2016-10-30 14:03:46 -04:00
nyuszika7h
57a628f135 Update help text for !say/!act
No longer requires !f prefix so display the preferred command names
in the help text.
2016-10-29 23:26:35 +02:00