Update FightBot.py
This commit is contained in:
parent
8bc469a5d5
commit
173aeac97f
64
FightBot.py
64
FightBot.py
@ -177,7 +177,12 @@ async def heal(name):
|
||||
if havebandages == None:
|
||||
await bot.sendmsg(config.irc.channel, f'[You do not have any bandages... !buy bandages <amount number>]')
|
||||
return
|
||||
|
||||
c.execute(f'SELECT * FROM items WHERE name = (:name)', {'name': name})
|
||||
bandaids = c.fetchall()
|
||||
for bandages in bandaids:
|
||||
if bandages[1] <= 0:
|
||||
await bot.sendmsg(config.irc.channel, f'[You do not have any bandages... !buy bandages <amount number>]')
|
||||
return
|
||||
maxhealth = userinfo[7]
|
||||
if health == maxhealth:
|
||||
await bot.sendmsg(config.irc.channel, f'[You already at FULL HEALTH]')
|
||||
@ -423,6 +428,12 @@ async def removeuser(nick):
|
||||
name = nick
|
||||
c.execute('''DELETE FROM users WHERE name=?''',(name,))
|
||||
conn.commit()
|
||||
c.execute('''DELETE FROM items WHERE name=?''',(name,))
|
||||
conn.commit()
|
||||
c.execute('''DELETE FROM weapons WHERE name=?''',(name,))
|
||||
conn.commit()
|
||||
c.execute('''DELETE FROM stats WHERE name=?''',(name,))
|
||||
conn.commit()
|
||||
logging.debug(f'Removed user {nick}')
|
||||
|
||||
async def createuser(nick):
|
||||
@ -683,6 +694,23 @@ async def getmoney(nick):
|
||||
moneyamount = money[6]
|
||||
writemoney = f'{moneyamount:,}'
|
||||
await bot.sendmsg(config.irc.channel, f'[Bank Balance: ${color(writemoney, light_blue)}]')
|
||||
async def getbandages(nick):
|
||||
name = nick
|
||||
c.execute(f'SELECT rowid FROM items WHERE name=(:name)', {'name': nick})
|
||||
data=c.fetchone()
|
||||
if data is None:
|
||||
bandages = 0
|
||||
c.execute(f'INSERT OR REPLACE INTO items VALUES (:name, :bandages)', {'name': name, 'bandages': bandages})
|
||||
conn.commit()
|
||||
c.execute(f"SELECT * FROM items WHERE name=(:name)", {'name': nick})
|
||||
bandages = c.fetchall()
|
||||
for bandage in bandages:
|
||||
bandageamount = bandage[1]
|
||||
if bandageamount == None:
|
||||
logging.debug('test')
|
||||
bandageamount = 0
|
||||
writebandageamount = f'{bandageamount:,}'
|
||||
await bot.sendmsg(config.irc.channel, f'[Bandages: {color(writebandageamount, red)}]')
|
||||
|
||||
async def ammo(nick):
|
||||
c.execute(f'SELECT rowid FROM users WHERE name=(:name)', {'name': nick})
|
||||
@ -759,7 +787,7 @@ class Bot():
|
||||
|
||||
time.sleep(config.throttle.msg)
|
||||
except:
|
||||
await bot.sendmsg(config.irc.channel, "Slow Down Nerd!")
|
||||
await bot.sendmsg(config.irc.channel, "Slow down homie!!")
|
||||
|
||||
async def connect(self):
|
||||
'''Connect to the IRC server.'''
|
||||
@ -814,7 +842,7 @@ class Bot():
|
||||
await self.raw(f'JOIN {chan}')
|
||||
elif args[1] == 'PRIVMSG':
|
||||
ident = args[0][1:]
|
||||
nick = args[0].split('!')[0][1:]
|
||||
nick = args[0].split('!')[0][1:].lower()
|
||||
target = args[2]
|
||||
msg = ' '.join(args[3:])[1:]
|
||||
arguments = msg.split()
|
||||
@ -845,7 +873,6 @@ class Bot():
|
||||
await buyweapon(nick)
|
||||
elif arguments[1] == 'ammo':
|
||||
await buyammo(nick)
|
||||
|
||||
elif arguments[1] == 'bandages':
|
||||
if len(arguments) <= 2 or int(arguments[2]) == 0:
|
||||
await bot.sendmsg(config.irc.channel, '[You must specify amount of bandages (greater than 0) to purchase]')
|
||||
@ -853,7 +880,7 @@ class Bot():
|
||||
await buybandages(nick, int(arguments[2]))
|
||||
|
||||
if arguments[0] == '!shoot':
|
||||
await shoot(arguments[1], nick)
|
||||
await shoot(arguments[1].lower(), nick)
|
||||
if arguments[0] == '!reload':
|
||||
await reload(nick)
|
||||
if arguments[0] == '!ammo':
|
||||
@ -873,6 +900,7 @@ class Bot():
|
||||
await bot.sendmsg(config.irc.channel, '[!buy <item> [weapon, ammo, bandages <amount>]')
|
||||
await bot.sendmsg(config.irc.channel, '[!reload - Reloads Weapon]')
|
||||
await bot.sendmsg(config.irc.channel, '[!ammo - Show Ammunition Amounts]')
|
||||
await bot.sendmsg(config.irc.channel, '[!bandages - Shows Bandage Amounts]')
|
||||
await bot.sendmsg(config.irc.channel, '[!revive - Brings you back to health if dead]')
|
||||
await bot.sendmsg(config.irc.channel, '[!heal - Use bandages to regain health]')
|
||||
await bot.sendmsg(config.irc.channel, ' ')
|
||||
@ -883,25 +911,29 @@ class Bot():
|
||||
await bot.sendmsg(config.irc.channel, '[!removeweapon <user> - Remove user weapon]')
|
||||
if arguments[0] == '!bank':
|
||||
await getmoney(nick)
|
||||
if arguments[0] == '!bandages':
|
||||
await getbandages(nick)
|
||||
|
||||
if nick in config.irc.admins:
|
||||
#await self.sendmsg(target, f'{nick} is an ' + color('Admin!', red))
|
||||
if arguments[0] == '!removeweapon':
|
||||
await removeweapon(nick)
|
||||
if arguments[0] == '!adduser':
|
||||
name = arguments[1]
|
||||
name = arguments[1].lower()
|
||||
|
||||
c.execute(f"SELECT rowid FROM users WHERE name = (:name)", {'name': name})
|
||||
|
||||
data=c.fetchone()
|
||||
if data is None:
|
||||
await bot.sendmsg(config.irc.channel, 'Registering Player: %s'%name)
|
||||
await bot.sendmsg(config.irc.channel, '[Registering Player: %s]'%name)
|
||||
await createuser(name)
|
||||
await profile(name)
|
||||
else:
|
||||
await bot.sendmsg(config.irc.channel, f'{color("Player already exists!", red)}')
|
||||
await bot.sendmsg(config.irc.channel, f'{color("[Player already exists!]", red)}')
|
||||
|
||||
if arguments[0] == '!remove':
|
||||
logging.debug('remove user')
|
||||
name = arguments[1]
|
||||
name = arguments[1].lower()
|
||||
c.execute(f"SELECT rowid FROM users WHERE name= (:name)", {'name': name})
|
||||
data=c.fetchone()
|
||||
if data != None:
|
||||
@ -911,33 +943,29 @@ class Bot():
|
||||
await bot.sendmsg(config.irc.channel, f'[User does not exist]')
|
||||
|
||||
if arguments[0] == '!setlevel':
|
||||
await setlevel(arguments[1], arguments[2])
|
||||
await setlevel(arguments[1].lower(), arguments[2])
|
||||
if arguments[0] == '!register':
|
||||
c.execute(f"SELECT rowid FROM users WHERE name = (:name)", {'name': nick})
|
||||
|
||||
data=c.fetchone()
|
||||
if data is None:
|
||||
await bot.sendmsg(config.irc.channel, 'Registering Player: %s'%nick)
|
||||
await bot.sendmsg(config.irc.channel, f'[Registering Player: %s]'%nick)
|
||||
await createuser(nick)
|
||||
await profile(nick)
|
||||
else:
|
||||
await bot.sendmsg(config.irc.channel, f'{color("Player already exists!", red)}')
|
||||
await bot.sendmsg(config.irc.channel, f'{color("[Player already exists!]", red)}')
|
||||
if arguments[0] == '!profile':
|
||||
try:
|
||||
await profile(arguments[1])
|
||||
await profile(arguments[1].lower())
|
||||
except:
|
||||
await profile(nick)
|
||||
if arguments[0] == '!punch':
|
||||
|
||||
await punch(arguments[1].lower(), nick)
|
||||
if msg == '!hello':
|
||||
await self.sendmsg(target, f'Hello {nick}! Do you like ' + color('colors?', green))
|
||||
|
||||
config.throttle.last = time.time()
|
||||
except Exception as ex:
|
||||
if time.time() - config.throttle.last < config.throttle.cmd:
|
||||
if not config.throttle.slow:
|
||||
await bot.sendmsg(config.irc.channel, color('Slow down nerd!', red))
|
||||
await bot.sendmsg(config.irc.channel, color('Slow down homie!', red))
|
||||
config.throttle.slow = True
|
||||
config.throttle.last = time.time()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user