Updated plugins to work with latest db changes.
This commit is contained in:
parent
375668d490
commit
80152d3002
3 changed files with 37 additions and 35 deletions
|
@ -65,9 +65,9 @@ class Plugin(PluginBase):
|
|||
if len(parts) == 1:
|
||||
insert_user(source_nick)
|
||||
|
||||
cookies = c_db.get_user(source_nick, 2)
|
||||
cookies = c_db.get_user_value(source_nick, 2)
|
||||
rnd = random.randint(1, 10)
|
||||
last = datetime.strptime(c_db.get_user(source_nick, 3), df)
|
||||
last = datetime.strptime(c_db.get_user_value(source_nick, 3), df)
|
||||
current = datetime.strptime(datetime.now().strftime(df), df)
|
||||
diff = round((current - last).total_seconds() / 60.0)
|
||||
|
||||
|
@ -82,7 +82,7 @@ class Plugin(PluginBase):
|
|||
await self.bot.ircsend(f'PRIVMSG {channel} :\x01ACTION gives {c1} to {source_nick}.\x01')
|
||||
await self.bot.ircsend(f'PRIVMSG {channel} :You now have a total of {c2}.')
|
||||
|
||||
c_db.set_user(source_nick, {
|
||||
c_db.set_user_values(source_nick, {
|
||||
'cookies': (cookies + rnd),
|
||||
'last': current.strftime(df)
|
||||
})
|
||||
|
@ -90,7 +90,7 @@ class Plugin(PluginBase):
|
|||
rem = remaining_time(last.strftime(df), 30 * 60000)
|
||||
await self.bot.ircsend(f'PRIVMSG {channel} :Remaining time: {rem}')
|
||||
elif len(parts) == 2:
|
||||
cookies = c_db.get_user(parts[1], 2)
|
||||
cookies = c_db.get_user_value(parts[1], 2)
|
||||
|
||||
if cookies == -1:
|
||||
await self.bot.ircsend(f'PRIVMSG {channel} :I\'ve looked everywhere for {parts[1]}\'s cookies, '
|
||||
|
|
10
pantsu.py
10
pantsu.py
|
@ -64,10 +64,10 @@ class Plugin(PluginBase):
|
|||
if len(parts) == 1:
|
||||
insert_user(source_nick)
|
||||
|
||||
pantsu = db.get_user(source_nick, 2)
|
||||
pantsu = db.get_user_value(source_nick, 2)
|
||||
rnd = random.randint(1, 8)
|
||||
new_pantsu = pantsu + rnd
|
||||
last = datetime.strptime(db.get_user(source_nick, 3), df)
|
||||
last = datetime.strptime(db.get_user_value(source_nick, 3), df)
|
||||
current = datetime.strptime(datetime.now().strftime(df), df)
|
||||
diff = round((current - last).total_seconds() / 60.0)
|
||||
chance = 0.10
|
||||
|
@ -79,7 +79,7 @@ class Plugin(PluginBase):
|
|||
|
||||
new_pantsu = pantsu - rnd
|
||||
if new_pantsu <= 0:
|
||||
db.set_user(source_nick, {
|
||||
db.set_user_values(source_nick, {
|
||||
'pantsu': (pantsu - rnd),
|
||||
'last': current.strftime(df)
|
||||
})
|
||||
|
@ -87,7 +87,7 @@ class Plugin(PluginBase):
|
|||
await self.bot.action(channel, f'gives {rnd} pantsu to {source_nick}.')
|
||||
await self.bot.privmsg(channel, f'You now have a total of {new_pantsu} pantsu.')
|
||||
|
||||
db.set_user(source_nick, {
|
||||
db.set_user_values(source_nick, {
|
||||
'pantsu': new_pantsu,
|
||||
'last': current.strftime(df)
|
||||
})
|
||||
|
@ -95,7 +95,7 @@ class Plugin(PluginBase):
|
|||
rem = remaining_time(last.strftime(df), 30 * 60000)
|
||||
await self.bot.privmsg(channel, f'You have to wait {rem} before you can get more pantsu.')
|
||||
elif len(parts) == 2:
|
||||
pantsu = db.get_user(parts[1], 2)
|
||||
pantsu = db.get_user_value(parts[1], 2)
|
||||
|
||||
if pantsu == -1:
|
||||
await self.bot.privmsg(channel, f'I\'ve looked everywhere for {parts[1]}\'s pantsu, but I couldn\'t'
|
||||
|
|
54
pat.py
54
pat.py
|
@ -67,15 +67,15 @@ class Plugin(PluginBase):
|
|||
insert_user(source_nick)
|
||||
|
||||
if len(parts) == 1:
|
||||
pats = db.get_user(source_nick, 2)
|
||||
last = datetime.strptime(db.get_user(source_nick, 5), df)
|
||||
pats = db.get_user_value(source_nick, 2)
|
||||
last = datetime.strptime(db.get_user_value(source_nick, 5), df)
|
||||
now = datetime.strptime(datetime.now().strftime(df), df)
|
||||
diff = round((now - last).total_seconds() / 60.0)
|
||||
|
||||
if diff >= 15:
|
||||
await self.bot.action(channel, f'gives 1 pat to {source_nick}.')
|
||||
|
||||
db.set_user(source_nick, {
|
||||
db.set_user_values(source_nick, {
|
||||
'pats': (pats + 1),
|
||||
'patLast': now.strftime(df)
|
||||
})
|
||||
|
@ -85,45 +85,47 @@ class Plugin(PluginBase):
|
|||
elif len(parts) == 2: # Pat someone
|
||||
if self.bot.config['Connection']['Nick'] != parts[1]:
|
||||
if source_nick != parts[1]:
|
||||
pats = db.get_user(parts[1], 2)
|
||||
patted = db.get_user(source_nick, 3)
|
||||
patted_t = db.get_user(parts[1], 4)
|
||||
last = datetime.strptime(db.get_user(parts[1], 6), df)
|
||||
now = datetime.strptime(datetime.now().strftime(df), df)
|
||||
diff = round((now - last).total_seconds() / 60.0)
|
||||
if db.get_user_values(parts[1]) == -1:
|
||||
return await self.bot.privmsg(channel, 'Those who haven\'t played yet shall not be patted.')
|
||||
|
||||
headpat = bool(random.choices([True, False], weights=[0.10, 0.90])[0])
|
||||
source_data = db.get_user_values(source_nick)[0]
|
||||
target_data = db.get_user_values(parts[1])[0]
|
||||
|
||||
last = datetime.strptime(source_data[6], df)
|
||||
curr = datetime.strptime(datetime.now().strftime(df), df)
|
||||
diff = round((curr - last).total_seconds() / 60.0)
|
||||
|
||||
if diff >= 30:
|
||||
if pats >= 1:
|
||||
if source_data[2] >= 1:
|
||||
if headpat:
|
||||
await self.bot.action(channel, f'pats {parts[1]} on the head.')
|
||||
else:
|
||||
await self.bot.action(channel, f'pats {parts[1]}.')
|
||||
|
||||
db.set_user(parts[1], {
|
||||
'pats': (pats - 1),
|
||||
'pattedTimes': (patted_t + 1),
|
||||
'pattedLast': now.strftime(df)
|
||||
db.set_user_values(source_nick, {
|
||||
'pats': (source_data[2] - 1),
|
||||
'pattedTimes': (source_data[4] + 1),
|
||||
'pattedLast': curr
|
||||
})
|
||||
db.set_user(source_nick, {
|
||||
'patted': (patted + 1)
|
||||
db.set_user_values(parts[1], {
|
||||
'patted': (target_data[3] + 1)
|
||||
})
|
||||
elif pats == -1:
|
||||
await self.bot.privmsg(channel, 'This user doesn\'t exist (yet).')
|
||||
else:
|
||||
await self.bot.privmsg(channel, 'You don\'t have enough pats left to pat someone.')
|
||||
else:
|
||||
rem = remaining_time(last.strftime(df), 30 * 60000)
|
||||
await self.bot.privmsg(channel, f'You have to wait {rem} before you can pat someone again.')
|
||||
rem = remaining_time(target_data[6], 30 * 60000)
|
||||
await self.bot.privmsg(channel, f'You have to wait {rem} before you can pat {parts[1]} '
|
||||
f'again.')
|
||||
else:
|
||||
await self.bot.privmsg(channel, 'You cannot pat yourself.')
|
||||
else:
|
||||
await self.bot.privmsg(channel, 'I\'m not able to pat myself.')
|
||||
elif parts[0].lower() == '!pats':
|
||||
if len(parts) == 1:
|
||||
pats = db.get_user(source_nick, 2)
|
||||
patted = db.get_user(source_nick, 3)
|
||||
patted_t = db.get_user(source_nick, 4)
|
||||
pats = db.get_user_value(source_nick, 2)
|
||||
patted = db.get_user_value(source_nick, 3)
|
||||
patted_t = db.get_user_value(source_nick, 4)
|
||||
|
||||
if pats >= 0:
|
||||
await self.bot.privmsg(channel, f'{source_nick} has patted others {patted_t} time(s), '
|
||||
|
@ -131,9 +133,9 @@ class Plugin(PluginBase):
|
|||
else:
|
||||
await self.bot.privmsg(channel, 'You haven\'t played this game yet, there\'s nothing to show.')
|
||||
elif len(parts) == 2:
|
||||
pats = db.get_user(parts[1], 2)
|
||||
patted = db.get_user(parts[1], 3)
|
||||
patted_t = db.get_user(parts[1], 4)
|
||||
pats = db.get_user_value(parts[1], 2)
|
||||
patted = db.get_user_value(parts[1], 3)
|
||||
patted_t = db.get_user_value(parts[1], 4)
|
||||
|
||||
if pats >= 0:
|
||||
await self.bot.privmsg(channel, f'{parts[1]} has patted others {patted_t} time(s), '
|
||||
|
|
Loading…
Add table
Reference in a new issue