2017-01-11 21:22:08

__module_name__  = "bot.py"

__module_version__ = "1.0"

__module_description__ = "Shows attack and sab logs"

print "\0034",__module_name__, __module_version__,"has been loaded\003"

import xchat

import pymysql

import locale

myhost = 'localhost'

myuser = 'script'

mypass = '4nt1v1rus$'

mydb = 'fatality'

global sconn

sconn = pymysql.connect(host=myhost, user=myuser, passwd=mypass, db=mydb)

global scur

scur = sconn.cursor()

scur.execute("SELECT time FROM logs ORDER BY time DESC LIMIT 1")

for r in scur:

global sdate

sdate = str(r[0])

def main(userdata):

locale.setlocale(locale.LC_ALL, '')

global sconn

global scur

global sdate

search = scur.execute("SELECT user, target, gold, type, time FROM logs WHERE time >= '"+str(sdate)+"' ORDER BY time ASC")

if search:

for e in scur:

user = e[0]

target = e[1]

gold = e[2]

type = e[3]

xchat.command('msg #St0rm '+str(user)+' stole '+str(locale.format("%1.0f", gold, grouping=True))+' gold from '+str(target)+'')

return 1 # Keep the timeout going


return 1

xchat.hook_timer(30000, main)