Merge pull request #2 from tippero/master

up to date
master
jw 5 years ago committed by GitHub
commit 0a49452315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)
@ -194,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:')
like.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')
@ -251,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))

@ -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
},

@ -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()+20])
if link.network.is_identified(link):
RunNextCommand(link,True)
else:
@ -58,6 +59,17 @@ 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]<now:
link=calltable[identity][0][0]
log_info('deleting old command: %s, %s' % (str(calltable[identity][0][1]), str(calltable[identity][0][3])))
link.send("Nickserv didn't reply, gonna have to deny access, mate")
del calltable[identity][0]
Unlock()
def Commands(link,cmd):
if IsAdmin(link):
all = True
@ -169,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:
@ -213,6 +225,7 @@ def RunIdleFunctions(param=None):
log_error("Exception running idle function %s from module %s: %s" % (str(f),module,str(e)))
finally:
Unlock()
PruneOldWaitingCommands()
def RunModuleHelpFunction(module,link):
if module in modules:

@ -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'],

@ -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)

@ -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]:

@ -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)

Loading…
Cancel
Save