def __init__(self, guild_id, key_name, name): self.guild_id = guild_id self.key_name = key_name self.name = name results = sqlutil.db_get_data('wait2datetime', {'guild_id':self.guild_id, 'key_name':self.key_name}) if len(results) == 0: sqlutil.db_set_data('wait2datetime', {'guild_id':self.guild_id, 'key_name':self.key_name}, {}) results = sqlutil.db_get_data('wait2datetime', {'guild_id':self.guild_id, 'key_name':self.key_name}) for result in results: if result[2] is not None: self.time = result[2] if result[3] is not None: self.channel_id = int(result[3]) self.update_checked()
def __init__(self, id): self.id = id self.tzinfo = datetime.timezone(datetime.timedelta(hours=0)) results = sqlutil.db_get_data('guild', {'id':self.id}) if len(results) == 0: sqlutil.db_set_data('guild', {'id':self.id}, {}) results = sqlutil.db_get_data('guild', {'id':self.id}) for result in results: if result[1] is not None: self.tzinfo = datetime.timezone(datetime.timedelta(hours=int(result[1]))) self.waitToDatetime['fb_1'] = WaitToDatetimeForm(self.id, 'fb_1', '숲필보 젠') self.waitToDatetime['fb_2'] = WaitToDatetimeForm(self.id, 'fb_2', '도심필보 젠') self.waitToDatetime['fb_moring'] = WaitToDatetimeForm(self.id, 'fb_moring', '모링포니아 젠')
async def command_memo(self, message, args): if len(args) > 0: if args[0] == '쓰기': key_name = None content = None lines = message.content.split('\n') if len(lines) > 1: content = message.content.replace(lines[0]+'\n', '') if len(args) > 1: key_name = args[1].split('\n')[0] if key_name is None: await message.channel.send('형식이 올바르지 않습니다.') else: sqlutil.db_set_data('memo', {'user_id':message.author.id, 'key_name':key_name}, {'content':content}) await message.channel.send(f'**[{key_name}]**메모 저장 완료.') # elif args[0] == '삭제': # key_name = None # if len(args) > 1: # key_name = args[1].replace('\n','') # if key_name is None: # await message.channel.send('형식이 올바르지 않습니다.') # else: # print('query') # print('succes chat') else: key_name = args[0].replace('\n','') results = sqlutil.db_get_data('memo', {'user_id':message.author.id, 'key_name':key_name}) if results is not None and len(results) > 0: await message.channel.send(f'<@{message.author.id}>님의 **[{key_name}]**메모.\n```{results[0][2]}```') else: await message.channel.send(f'[{key_name}]메모에 내용이 없습니다.') else: help_message = '**- 메모 보기**\n' help_message += '```./메모 [메모이름]```\n' help_message += '**- 메모 쓰기**\n' help_message += '```./메모쓰기 [메모이름]\n[메모내용]```\n' await message.channel.send(help_message)
def set_time(self, time): self.time = time self.update_checked() sqlutil.db_set_data('wait2datetime', {'guild_id':self.guild_id, 'key_name':self.key_name}, {'time':self.time})
def set_channel_id(self, ch_id): self.channel_id = ch_id sqlutil.db_set_data('wait2datetime', {'guild_id':self.guild_id, 'key_name':self.key_name}, {'channel_id':self.channel_id})
def set_timezone(self, hour): self.tzinfo = datetime.timezone(datetime.timedelta(hours=hour)) sqlutil.db_set_data('guild', {'id':self.id}, {'timezone':hour})