From 64749a9afa932fd00f9c339d89c32fe5c5dcfd13 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Mon, 6 Nov 2017 23:27:52 +0000 Subject: [PATCH 01/11] command_manager: time out on auth If we miss a nickserv reply, delete the scheduled command --- tipbot/command_manager.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tipbot/command_manager.py b/tipbot/command_manager.py index 0bf555b..12ac726 100644 --- a/tipbot/command_manager.py +++ b/tipbot/command_manager.py @@ -9,6 +9,7 @@ # any later version. # +import time import tipbot.config as config from tipbot.utils import * @@ -23,7 +24,7 @@ def SendToProxy(link,msg): def RunRegisteredCommand(link,ifyes,yesdata,ifno,nodata): if link.identity() not in calltable: calltable[link.identity()] = [] - calltable[link.identity()].append([link,ifyes,yesdata,ifno,nodata]) + calltable[link.identity()].append([link,ifyes,yesdata,ifno,nodata,time.time()+10]) if link.network.is_identified(link): RunNextCommand(link,True) else: @@ -58,6 +59,16 @@ def RunNextCommand(link,registered): finally: Unlock() +def PruneOldWaitingCommands(): + Lock() + now=time.time() + for identity in calltable.keys(): + while len(calltable[identity])>0 and calltable[identity][0][5] Date: Tue, 7 Nov 2017 23:53:33 +0000 Subject: [PATCH 02/11] command_manager: never tweak one last thing after testing --- tipbot/command_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tipbot/command_manager.py b/tipbot/command_manager.py index 12ac726..217f555 100644 --- a/tipbot/command_manager.py +++ b/tipbot/command_manager.py @@ -64,6 +64,7 @@ def PruneOldWaitingCommands(): now=time.time() for identity in calltable.keys(): while len(calltable[identity])>0 and calltable[identity][0][5] Date: Sun, 12 Nov 2017 11:59:36 +0000 Subject: [PATCH 03/11] Start ignoring !balance from blackbaba in public channels --- tipbot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tipbot.py b/tipbot.py index de966da..d993899 100644 --- a/tipbot.py +++ b/tipbot.py @@ -108,6 +108,9 @@ for modulename in modulenames: def GetBalance(link,cmd): nick=link.user.nick + if link.group and nick.startswith('blackbab'): + link.send_private("Stop spamming the public channel") + return try: balance,confirming = RetrieveBalance(link) sbalance = AmountToString(balance) From e6888fde5d0b28b51359969fa4d5fccd637cf1f7 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Sun, 12 Nov 2017 12:21:21 +0000 Subject: [PATCH 04/11] command_manager: double the nickserv timeout --- tipbot/command_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tipbot/command_manager.py b/tipbot/command_manager.py index 217f555..8dfaa98 100644 --- a/tipbot/command_manager.py +++ b/tipbot/command_manager.py @@ -24,7 +24,7 @@ def SendToProxy(link,msg): def RunRegisteredCommand(link,ifyes,yesdata,ifno,nodata): if link.identity() not in calltable: calltable[link.identity()] = [] - calltable[link.identity()].append([link,ifyes,yesdata,ifno,nodata,time.time()+10]) + calltable[link.identity()].append([link,ifyes,yesdata,ifno,nodata,time.time()+20]) if link.network.is_identified(link): RunNextCommand(link,True) else: From d56c6dd61b7f10c55dd57edf67a61ae0660978be Mon Sep 17 00:00:00 2001 From: moneromooo Date: Tue, 14 Nov 2017 22:30:38 +0000 Subject: [PATCH 05/11] spammer: fix allowed list check --- tipbot/modules/spammer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tipbot/modules/spammer.py b/tipbot/modules/spammer.py index 237f364..7a8122d 100644 --- a/tipbot/modules/spammer.py +++ b/tipbot/modules/spammer.py @@ -71,7 +71,7 @@ def OnMessage(event,*args,**kwargs): link=kwargs['link'] if IsAdmin(link): return - if link.nick in config.allowed: + if config.spammer_allowed and link.user.nick in config.spammer_allowed: return line=re.sub(r'\x03[0-9]?[0-9]?','',line) From 25789e5948f7ccb6383cddc24ce5d398d80fec88 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 22 Nov 2017 10:23:15 +0000 Subject: [PATCH 06/11] fix typo in linking_accounts which would make the command throw --- tipbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tipbot.py b/tipbot.py index d993899..81a9db6 100644 --- a/tipbot.py +++ b/tipbot.py @@ -197,7 +197,7 @@ def LinkingAccounts(link,cmd): link.send_private('any account interchangeably. If the accounts are on different networks') link.send_private('(eg, IRC and Reddit), the user names need to be prefixed with the network\'s') link.send_private('name (freenode: for Freenode IRC, reddit: for Reddit), like this:') - like.send_private(' !link_account reddit:myredditname') + link.send_private(' !link_account reddit:myredditname') link.send_private('Linking accounts is irreversible, so make sure you only link to accounts') link.send_private('under your control') From 48f677d28cd1f3d9d8b30e39b790a4cfe9eb0f84 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 22 Nov 2017 10:25:29 +0000 Subject: [PATCH 07/11] make the !linking_accounts blurb more explicit --- tipbot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tipbot.py b/tipbot.py index 81a9db6..ca7eb0c 100644 --- a/tipbot.py +++ b/tipbot.py @@ -197,7 +197,8 @@ def LinkingAccounts(link,cmd): link.send_private('any account interchangeably. If the accounts are on different networks') link.send_private('(eg, IRC and Reddit), the user names need to be prefixed with the network\'s') link.send_private('name (freenode: for Freenode IRC, reddit: for Reddit), like this:') - link.send_private(' !link_account reddit:myredditname') + link.send_private(' !link_account reddit:myredditname (do that on Freenode)') + link.send_private(' !link_account freenode:myircnick (do that on Reddit)') link.send_private('Linking accounts is irreversible, so make sure you only link to accounts') link.send_private('under your control') From 236a90632853511b896cbf7d0c455c20cb503b4d Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 25 Apr 2018 14:59:05 +0100 Subject: [PATCH 08/11] coinspecs: allow 8 (mainnet subaddresses) and A (standard testnet address) prefixes --- tipbot/coinspecs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tipbot/coinspecs.py b/tipbot/coinspecs.py index a6c0b76..e27d01b 100644 --- a/tipbot/coinspecs.py +++ b/tipbot/coinspecs.py @@ -16,7 +16,7 @@ coinspecs = { "atomic_units": 1e12, "denominations": [[1000000, 1, "piconero"], [1000000000, 1e6, "micronero"], [1000000000000, 1e9, "millinero"]], "address_length": [[95, 95], [106, 106]], # min/max size of addresses - "address_prefix": ['4', '9'], # allowed prefixes of addresses + "address_prefix": ['4', '8', '9', 'A'], # allowed prefixes of addresses "min_withdrawal_fee": 10000000000, "web_wallet_url": "https://mymonero.com/", # None is there's none }, From 259aed3c661a24084b581409bc0709aadf94c215 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Fri, 4 May 2018 19:12:02 +0100 Subject: [PATCH 09/11] freenode: guard against Freenode impersonation "feature" Freenode allows impersonating registered users for 30 seconds, so don't consider users registered before we've known them for at least a minute. And be a bit paranoid about it with parts and joins. --- tipbot/command_manager.py | 2 +- tipbot/modules/freenode.py | 6 ++++++ tipbot/modules/irc.py | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tipbot/command_manager.py b/tipbot/command_manager.py index 8dfaa98..41381c3 100644 --- a/tipbot/command_manager.py +++ b/tipbot/command_manager.py @@ -181,7 +181,7 @@ def OnCommand(link,cmd,check_admin,check_registered): if 'admin' in c and c['admin']: check_admin(link,c['function'],cmd,SendToProxy,"You must be admin") elif 'registered' in c and c['registered']: - check_registered(link,c['function'],cmd,SendToProxy,"You must be registered with Freenode") + check_registered(link,c['function'],cmd,SendToProxy,"You must be registered with Freenode, or known for a minute") else: Lock() try: diff --git a/tipbot/modules/freenode.py b/tipbot/modules/freenode.py index c6cfede..0e11562 100644 --- a/tipbot/modules/freenode.py +++ b/tipbot/modules/freenode.py @@ -28,6 +28,12 @@ class FreenodeNetwork(IRCNetwork): def identify(self,link): nick = link.user.nick + t = self.is_known(nick) + if t < 60: + log_info('%s is not known, or only time for %d seconds' % (nick, t)) + if self.on_identified: + self.on_identified(link,False) + return log_info('Asking nickserv whether %s is identified' % nick) self.send_to('nickserv', "ACC " + nick) diff --git a/tipbot/modules/irc.py b/tipbot/modules/irc.py index 7ce4fe1..99c17c7 100644 --- a/tipbot/modules/irc.py +++ b/tipbot/modules/irc.py @@ -45,6 +45,7 @@ class IRCNetwork(Network): self.current_send_delay = irc_min_send_delay self.quitting = False self.buffered_data = "" + self.known = {} def connect(self): try: @@ -166,6 +167,19 @@ class IRCNetwork(Network): return True return False + def evict_known(self, nick): + del self.known[nick] + self.registered_users.discard(Link(self,User(self,nick),None).identity()) + log_info("now unknown: " + Link(self,User(self,nick),None).identity()) + + def add_known(self, nick): + self.known[nick] = time.time() + self.registered_users.discard(Link(self,User(self,nick),None).identity()) + log_info("now known: " + Link(self,User(self,nick),None).identity()) + + def is_known(self, nick): + return time.time() - self.known[nick] if nick in self.known else 0 + def update(self): try: data=self._getline() @@ -306,6 +320,7 @@ class IRCNetwork(Network): if who_chan_user[0] in ["@","+"]: who_chan_user = who_chan_user[1:] self.userstable[who_chan][who_chan_user] = None + self.add_known(who_chan_user) log_log("New list of users in %s: %s" % (who_chan, str(self.userstable[who_chan].keys()))) except Exception,e: log_error('Failed to parse "353" line: %s: %s' % (data, str(e))) @@ -331,6 +346,7 @@ class IRCNetwork(Network): elif action == 'JOIN': nick = GetNick(who) + self.add_known(nick) log_info('%s joined the channel' % nick) if not chan in self.userstable: self.userstable[chan] = dict() @@ -344,6 +360,7 @@ class IRCNetwork(Network): elif action == 'PART': nick = GetNick(who) + self.evict_known(nick) log_info('%s left the channel' % nick) if not nick in self.userstable[chan]: log_warn('%s left, but was not in %s' % (nick, chan)) @@ -355,6 +372,7 @@ class IRCNetwork(Network): elif action == 'QUIT': nick = GetNick(who) + self.evict_known(nick) log_info('%s quit' % nick) removed_list = "" for chan in self.userstable: @@ -383,6 +401,8 @@ class IRCNetwork(Network): nick = GetNick(who) new_nick = cparts[len(cparts)-1].lower() log_info('%s renamed to %s' % (nick, new_nick)) + self.evict_known(nick) + self.add_known(new_nick) for c in self.userstable: log_log('checking %s' % c) if nick in self.userstable[c]: From fc88e82f63b6f43e13194dd24cbd4b30bc4e9847 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Wed, 1 Aug 2018 15:15:05 +0100 Subject: [PATCH 10/11] config: add a few third party commands the bot ignores Avoids answering "unknown command" when the intended recipient is another bot also using ! --- tipbot/config.py.example | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tipbot/config.py.example b/tipbot/config.py.example index 0d8cf2e..8cab8b6 100644 --- a/tipbot/config.py.example +++ b/tipbot/config.py.example @@ -38,7 +38,9 @@ no_rain_to_nicks = [] # commands used by other bots, to avoid "unknown command" complaints silent_invalid_commands = { 'freenode': [ - 'price','worth','net','pools','calc','convert','val'] + 'price','worth','net','pools','calc','convert','val', + 'consume', 'getBalance', 'marketbuy', 'marketsell', 'owns', + 'buy', 'sell', 'quote'] } network_config = { @@ -52,7 +54,7 @@ network_config = { 'sasl_name': 'monero-tipbot', 'welcome_line': 'Welcome to the freenode Internet Relay Chat Network', 'timeout_seconds': 600, - 'channels': ['#txtptest000'], + 'channels': ['#txtptest000', '##ck-d20'], }, 'reddit': { 'subreddits': ['test'], From fccd94ecfbf45fab609c8df22679f852148fc0f7 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Fri, 5 Apr 2019 16:15:36 +0100 Subject: [PATCH 11/11] Point to github in info message --- tipbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tipbot.py b/tipbot.py index ca7eb0c..f55946c 100644 --- a/tipbot.py +++ b/tipbot.py @@ -255,7 +255,7 @@ def Help(link,cmd): def Info(link,cmd): link.send_private("Info for %s:" % config.tipbot_name) - link.send_private("Copyright 2014,2015 moneromooo - http://duckpool.mooo.com/tipbot/") + link.send_private("Copyright 2014,2015 moneromooo - https://github.com/tippero/tippero") link.send_private("Type !help, or !commands for a list of commands") link.send_private("NO WARRANTY, YOU MAY LOSE YOUR COINS") link.send_private("By sending your %s to %s, you are giving up their control" % (coinspecs.name, config.tipbot_name))