ifself.bot.con.all('select id from geeksbot_emojis where id = %(id)s',{'id':emoji.id}):
self.bot.con.run("update geeksbot_emojis set id = %(id)s, name = %(name)s, code = %(emoji_code)s where name = %(name)s",{'name':emoji.name,'id':emoji.id,'emoji_code':emoji_code})
ifself.bot.con.all('select id from geeksbot_emojis where id = %(id)s',{'id':emoji.id}):
self.bot.con.run("update geeksbot_emojis set id = %(id)s, name = %(name)s, code = %(emoji_code)s"
self.bot.con.run("insert into geeksbot_emojis(id,name,code) values (%(id)s,%(name)s,%(emoji_code)s)",{'name':emoji.name,'id':emoji.id,'emoji_code':emoji_code})
self.bot.con.run("insert into geeksbot_emojis(id,name,code) values (%(id)s,%(name)s,%(emoji_code)s)",
self.bot.con.run("insert into guild_config(guild_id,guild_name,admin_roles,rcon_enabled,channel_lockdown,raid_status,pg_filter,patreon_enabled,referral_enabled)\
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s',{'id':ctx.guild.id}))
server=server.replace('_','').title()
ifserverisnotNone:
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config\
whereguild_id=%(id)s', {'id': ctx.guild.id}))
server=server.replace('_','').title()
ifserverinrcon_connections:
rcon_connections[server]["monitoring_chat"]=1
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s',{'id':ctx.guild.id,'json':json.dumps(rcon_connections)})
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s',
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s',{'id':ctx.guild.id}))
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config\
whereguild_id=%(id)s', {'id': ctx.guild.id}))
awaitchannel.send('Monitoring Stopped')
else:
awaitctx.send(f'Server not found: {server}')
@ -181,15 +193,17 @@ class rcon():
@commands.command()
@commands.guild_only()
asyncdefend_monitor_chat(self,ctx,*,server=None):
'''Ends chat monitoring on the specified server.
Contextisthesameasmonitor_chat'''
"""Ends chat monitoring on the specified server.
Contextisthesameasmonitor_chat"""
ifchecks.is_rcon_admin(self.bot,ctx):
ifserver!=None:
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s',{'id':ctx.guild.id}))
server=server.replace('_','').title()
ifserverisnotNone:
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config\
whereguild_id=%(id)s', {'id': ctx.guild.id}))
server=server.replace('_','').title()
ifserverinrcon_connections:
rcon_connections[server]["monitoring_chat"]=0
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s',{'id':ctx.guild.id,'json':json.dumps(rcon_connections)})
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s',
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s',{'id':ctx.guild.id}))
ifserver!=None:
server=server.replace('_','').title()
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config\
whereguild_id=%(id)s', {'id': ctx.guild.id}))
ifserverisnotNone:
server=server.replace('_','').title()
ifserverinrcon_connections:
connection_info=rcon_connections[server]
msg=awaitctx.send('Getting Data for the {0} server'.format(server.title()))
@ -221,7 +237,8 @@ class rcon():
awaitmsg.delete()
awaitctx.send('Players currently on the {0} server:\n{1}'.format(server.title(),message))
else:
awaitctx.send('That server is not in my configuration.\nPlease add it via !add_rcon_server "{0}""ip" port "password" if you would like to get info from it.'.format(server))
awaitctx.send('That server is not in my configuration.\nPlease add it via !add_rcon_server "{0}"'
'"ip" port "password" if you would like to get info from it.'.format(server))
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s',{'id':ctx.guild.id}))
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config\
whereguild_id=%(id)s', {'id': ctx.guild.id}))
ifservernotinrcon_connections:
rcon_connections[server]={
'ip':ip,
'port':port,
'password':password,
'name':server.lower().replace('','_'),
'name':server.lower().replace('','_'),
'game_chat_chan_id':0,
'msg_chan_id':0,
'monitoring_chat':0
}
self.bot.con.run('update guild_config set rcon_connections = %(connections)s where guild_id = %(id)s',{'id':ctx.guild.id,'connections':json.dumps(rcon_connections)})
self.bot.con.run('update guild_config set rcon_connections = %(connections)s where guild_id = %(id)s',
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config where guild_id = %(id)s',{'id':ctx.guild.id}))
rcon_connections=json.loads(self.bot.con.one('select rcon_connections from guild_config\
whereguild_id=%(id)s', {'id': ctx.guild.id}))
ifserverinrcon_connections:
delrcon_connections[server]
self.bot.con.run('update guild_config set rcon_connections = %(connections)s where guild_id = %(id)s',{'id':ctx.guild.id,'connections':json.dumps(rcon_connections)})
self.bot.con.run('update guild_config set rcon_connections = %(connections)s where guild_id = %(id)s',
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s',{'id':ctx.guild.id,'json':json.dumps(rcon_connections)})
self.bot.con.run('update guild_config set rcon_connections = %(json)s where guild_id = %(id)s',
em.add_field(name=f'Activity:',value=f'{member.display_name} has sent {count}{"message"ifcount==1else"messages"} in the last hour to this channel.',inline=False)
em.add_field(name=f'Activity:',
value=f'{member.display_name} has sent {count}'
f'{"message"ifcount==1else"messages"} in the last hour to this channel.',
roles=self.bot.con.one(f'select admin_roles,rcon_admin_roles from guild_config where guild_id = {ctx.guild.id}')
request_id=self.bot.con.one(f'select id from admin_requests where issuing_member_id = %(member_id)s and request_time = %(time)s',{'member_id':ctx.author.id,'time':ctx.message.created_at})
roles=self.bot.con.one(f'select admin_roles,rcon_admin_roles from guild_config where '
f'guild_id = %(id)s',{'id':ctx.guild.id})
request_id=self.bot.con.one(f'select id from admin_requests where '
f'issuing_member_id = %(member_id)s and request_time = %(time)s',
msg+=f" New Request ID: {request_id}\n{ctx.author.mention} has requested assistance:\n```{request_msg}```\nRequested on: {datetime.strftime(ctx.message.created_at,'%Y-%m-%d at %H:%M:%S')} GMT"
Requestedon:{datetime.strftime(request[5],'%Y-%m-%d at %H:%M:%S')}GMT
""",
inline=False)
else:
em.add_field(name=f'There are no pending requests for {assigned_to.display_name} this guild.',value='',inline=False)
em.add_field(name=f'There are no pending requests for {assigned_to.display_name} this guild.',
value='',
inline=False)
else:
em.title=f'{assigned_to.display_name} is not an admin in this guild.'
else:
requests=self.bot.con.all('select * from admin_requests where issuing_member_id = %(member_id)s and guild_orig = %(guild_id)s and completed_time is null',
requests=self.bot.con.all('select * from admin_requests where issuing_member_id = %(member_id)s'
'and guild_orig = %(guild_id)s and completed_time is null',
em.add_field(name=f"Request ID: {request[0]}{' Assigned to: '+admin.display_nameifadminelse''}",value=f"{request[4]}\nRequested on: {datetime.strftime(request[5],'%Y-%m-%d at %H:%M:%S')} GMT\n",inline=False)
em.add_field(name=f"Request ID: {request[0]}"
f"{' Assigned to: '+admin.display_nameifadminelse''}",
value=f"""{request[4]}
Requestedon:{datetime.strftime(request[5],'%Y-%m-%d at %H:%M:%S')}GMT
""",
inline=False)
else:
em.add_field(name='You have no pending Admin Help requests.',value='To submit a request please use `admin new <message>`',inline=False)
em.add_field(name='You have no pending Admin Help requests.',
value='To submit a request please use `admin new <message>`',
awaitctx.send(f'{request_id} is not a valid request id.')
else:
request=self.bot.con.one(f'select * from admin_requests where id = %(request_id)s',{'request_id':request_id})
request=self.bot.con.one(f'select * from admin_requests where id = %(request_id)s',
{'request_id':request_id})
ifrequest:
ifrequest[3]==ctx.guild.id:
ifrequest[6]==None:
self.bot.con.run('update admin_requests set completed_time = %(time_now)s where id = %(request_id)s',{'time_now':ctx.message.created_at,'request_id':request_id})
awaitctx.send(f'Request {request_id} by {ctx.guild.get_member(request[1]).display_name} has been marked complete.')
ifrequest[6]isNone:
self.bot.con.run('update admin_requests set completed_time = %(time_now)s where '