How to use log_append method in autotest

Best Python code snippet using autotest_python

main.py

Source:main.py Github

copy

Full Screen

...26def url_encode(data):27 return (parse.quote(data).replace('/', '%2F'))28async def lifetime(msg,user):29 chat_id = msg.channel.id30 now = log_append(chat_id, str(msg.content), "lifetime",0)31 dup_num = user.lifetime_enable(now)32 if dup_num[0] < 3:33 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)34 text = mention_user(user.user_id)+" "+quadra_lifetime.checkSwitch(now)35 await bot.send_message(msg.channel,text)36 else:37 user.mody(love = -10)38 text = mention_user(user.user_id)+" "+quadra_lifetime.checkSwitch2(now, user.love_level())39 await bot.send_message(msg.channel,text)40async def dialog_how(msg,user):41 chat_id = msg.channel.id42 log_append(chat_id, str(msg.content), "d_how",0)43 target = re.search('^사잽아 ((?:(?! 어때).)*) 어때', str(msg.content))44 target = target.groups()45 user_list = msg.mentions46 47 if target[0] == "나":48 await bot.send_message(msg.channel,mention_user(user.user_id)+", 조금만 기다려줘! 시간이 좀 걸려!")49 level_stat = user.level50 cash_stat = user.cash51 if level_stat == quadra_user_module.MAX_LEVEL:52 req_exp = quadra_user_module.REQ_EXP[level_stat-1] - quadra_user_module.REQ_EXP[level_stat-2]53 cur_exp = user.exp - quadra_user_module.REQ_EXP[level_stat-1]54 elif level_stat != 0 :55 req_exp = quadra_user_module.REQ_EXP[level_stat] - quadra_user_module.REQ_EXP[level_stat-1]56 cur_exp = user.exp - quadra_user_module.REQ_EXP[level_stat-1]57 else :58 req_exp = quadra_user_module.REQ_EXP[level_stat]59 cur_exp = user.exp60 if level_stat != quadra_user_module.MAX_LEVEL:61 exp_bar = ""62 exp_perc = (cur_exp / req_exp)63 exp_perc *= 10064 exp_perc_str = "(%3d %%)"%(exp_perc)65 for i in range(0,10,1):66 if exp_perc >= 10:67 exp_bar += "■"68 exp_perc -= 1069 else: exp_bar += "□"70 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 프로필!",description="Lv."+str(level_stat)+" ( "+str(cur_exp)+" / "+str(req_exp)+" )\n"+exp_bar+exp_perc_str, colour=discord.Colour.blue())71 else : 72 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 프로필!",description="Lv."+str(level_stat)+" ( "+str(cur_exp)+" )\n■■■■■■■■■■(최대레벨)", colour=discord.Colour.blue())73 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)74 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")75 em.add_field(name="돈", value=str(cash_stat), inline=True)76 em.add_field(name="호감도", value=user.love_short(), inline=True)77 if level_stat == 100: em.add_field(name="누적 경험치",value=str(user.exp),inline=False)78 else : em.add_field(name="누적 경험치",value=str(user.exp)+" / "+str(quadra_user_module.REQ_EXP[level_stat]),inline=False)79 ranking = user.user_rank()80 em.add_field(name="순위",value=str(ranking[0])+" / "+str(ranking[1]),inline=True)81 await bot.send_message(msg.channel,mention_user(user.user_id)+",\n"+user.love_text(),embed = em)82 elif len(user_list) == 1 and user_list :83 await bot.send_message(msg.channel,mention_user(user.user_id)+", 조금만 기다려줘! 시간이 좀 걸려!")84 if user_list[0].bot == False :85 trg_user = quadra_user(user_list[0].id)86 level_stat = trg_user.level87 cash_stat = trg_user.cash88 if level_stat == quadra_user_module.MAX_LEVEL:89 req_exp = quadra_user_module.REQ_EXP[level_stat-1] - quadra_user_module.REQ_EXP[level_stat-2]90 cur_exp = trg_user.exp - quadra_user_module.REQ_EXP[level_stat-1]91 elif level_stat != 0 :92 req_exp = quadra_user_module.REQ_EXP[level_stat] - quadra_user_module.REQ_EXP[level_stat-1]93 cur_exp = trg_user.exp - quadra_user_module.REQ_EXP[level_stat-1]94 else :95 req_exp = quadra_user_module.REQ_EXP[level_stat]96 cur_exp = trg_user.exp97 if level_stat != quadra_user_module.MAX_LEVEL:98 exp_bar = ""99 exp_perc = (cur_exp / req_exp)100 exp_perc *= 100101 exp_perc_str = "(%3d %%)"%(exp_perc)102 for i in range(0,10,1):103 if exp_perc >= 10:104 exp_bar += "■"105 exp_perc -= 10106 else: exp_bar += "□"107 em = discord.Embed(title=user_list[0].name+"#"+str(user_list[0].discriminator)+" 의 프로필!",description="Lv."+str(level_stat)+" ( "+str(cur_exp)+" / "+str(req_exp)+" )\n"+exp_bar+exp_perc_str, colour=discord.Colour.blue())108 else : 109 em = discord.Embed(title=user_list[0].name+"#"+str(user_list[0].discriminator)+" 의 프로필!",description="Lv."+str(level_stat)+" ( "+str(cur_exp)+" )\n■■■■■■■■■■(최대레벨)", colour=discord.Colour.blue())110 if user_list[0].avatar_url: em.set_thumbnail(url=user_list[0].avatar_url)111 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")112 em.add_field(name="돈", value=str(cash_stat), inline=True)113 em.add_field(name="호감도", value=trg_user.love_short(), inline=True)114 if level_stat == 100: em.add_field(name="누적 경험치",value=str(trg_user.exp),inline=False)115 else : em.add_field(name="누적 경험치",value=str(trg_user.exp)+" / "+str(quadra_user_module.REQ_EXP[level_stat]),inline=False)116 ranking = trg_user.user_rank()117 em.add_field(name="순위",value=str(ranking[0])+" / "+str(ranking[1]),inline=True)118 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+user_list[0].name+"#"+str(user_list[0].discriminator)+"에 대해서 묻는거지?",embed = em)119 else :120 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+user_list[0].name+"#"+str(user_list[0].discriminator)+"는 봇이잖아!" )121 elif target[0] in quadra_search_vocab.dis_list: 122 text=random.choice(quadra_dialog_list.dialog_dis_how)123 user.mody(love = 2, love_time = True, exp = 5, exp_time = True)124 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)125 elif target[0] in quadra_search_vocab.adult_list:126 text=random.choice(quadra_dialog_list.dialog_hentai_how)127 inc = - 10 - 5*(quadra_user_module.MAX_LOVE - quadra_user_module.MIN_LOVE - user.love) / (quadra_user_module.MAX_LOVE-quadra_user_module.MIN_LOVE)128 user.mody(love = inc, exp = 5, exp_time = True)129 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)130 else:131 text="미안. 무슨 말인지 모르겠어."132 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)133 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)134async def dialog_please(msg,user):135 chat_id = msg.channel.id136 log_append(chat_id, str(msg.content), "d_plz",0)137 target = re.search('^사잽아 ((?:(?! (해줘|할래)).)*) (해줘|할래)', str(msg.content))138 target = target.groups()139 140 if target[0] == "자동로또":141 game_name = onGame(user.user_id)142 if game_name == "로또를":143 user_in = [10,10,10,10,10,10]144 for i in range(0,6,1):145 swt = True146 while(swt):147 temp = random.randrange(1,36)148 if temp in user_in:149 continue150 else:151 user_in[i] = temp152 swt = False153 user_in.sort()154 data = quadra_lotto.check(user.user_id)155 result = quadra_lotto.gameManager(user_in,data[0],data[1])156 user_in_text = ""157 for i in user_in:158 user_in_text += str(i)+" "159 log_append(chat_id,"player : "+user_in_text, "lt","p_at")160 text2 = mention_user(user.user_id)+", "161 text = ""162 for i in data[0]:163 text += str(i)+" "164 comp_in_text = text+": "+str(data[1])165 log_append(chat_id,"rank "+str(result)+", answer is "+text+": "+str(data[1]), "lt","p_cor")166 dif_cash = 0167 dif_love = 0168 dif_exp = 0169 if result == 1:170 text2 += "1등이네! 축하해!! 8,145,060 분의 1의 확률인데, 너무 대단한걸?"171 dif_love = 10172 dif_exp = 100173 dif_cash = 2500000000174 elif result == 2:175 text2 += "2등이야. 1등이 아니라 아쉽겠지만, 그래도 축하해!"176 dif_love = 5177 dif_exp = 50178 dif_cash = 10000000179 elif result == 3:180 text2 += "3등. 이정도면 꽤나 운이 좋은걸?"181 dif_love = 4182 dif_exp = 25183 dif_cash = 3000000184 elif result == 4:185 text2 += "4등. 733명 중 한명. 축하해."186 dif_love = 3187 dif_exp = 25188 dif_cash = 50000189 elif result == 5:190 dif_love = 2191 dif_exp = 25192 dif_cash = 5000193 text2 += "5등. 45명중의 한명이야. 그래도 본전은 뽑았을려나?"194 else: text2 += "지나친 도박은 좋지 않다구. 결국 다 잃어버리잖아.."195 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 로또 결과!",colour=discord.Colour.blue())196 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)197 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")198 em.add_field(name="방식",value="자동",inline=True)199 if result <= 5: em.add_field(name="등수",value=str(result)+"등",inline=True)200 else : em.add_field(name="등수",value="--",inline=True)201 em.add_field(name="당첨금",value=str(dif_cash)+" 원",inline=False)202 em.add_field(name="플레이어", value=user_in_text, inline=False)203 em.add_field(name="당첨번호", value=comp_in_text, inline=False)204 await bot.send_message(msg.channel,text2,embed = em)205 quadra_lotto.end(user.user_id)206 user.mody(love = dif_love, exp = dif_exp, cash = dif_cash)207 else: 208 log_append(chat_id,"there are no game playing", "gm","p_no")209 await bot.send_message(msg.channel,mention_user(user.user_id)+", 게임을 안하고 있는것같은데?")210 elif target[0] in quadra_search_vocab.dis_list: 211 out_text = random.choice(quadra_dialog_list.dialog_dis_please)212 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)213 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+out_text)214 elif target[0] in quadra_search_vocab.adult_list:215 out_text = random.choice(quadra_dialog_list.dialog_hentai_please)216 inc = -10-5*(quadra_user_module.MAX_LOVE - quadra_user_module.MIN_LOVE - user.love) / (quadra_user_module.MAX_LOVE-quadra_user_module.MIN_LOVE)217 user.mody(love = inc, exp = 5, exp_time = True)218 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+out_text)219 else:220 out_text = "미안. 뭘 해달라는건지 모르겠어."221 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)222 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+out_text)223async def dialog_do(msg,user):224 chat_id = msg.channel.id225 target = re.search('^사잽아 ((?:(?! 하자).)*) 하자', str(msg.content))226 target = target.groups()227 228 if target[0] == "야구게임":229 if onGame(user.user_id) == "야구게임을":230 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이미 플레이중인거 같은데?\n3자리 수를 생각해서 \"사잽아 ~ 맞아?\" 라고 말해줘.\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘.")231 elif onGame(user.user_id) !="" :232 out_text=mention_user(user.user_id)+", 이미 "+onGame(user.user_id)+" 플레이중인거 같은데?"233 await bot.send_message(msg.channel,out_text)234 else:235 log_append(chat_id,str(msg.content), "bb","start1")236 temp = quadra_baseball.start(user.user_id)237 log_append(chat_id,str(user.user_id)+" "+str(temp), "bb","start2")238 out_text=mention_user(user.user_id)+", 좋아! 이제 시작해보자~\n \"사잽아 ~ 맞아?\" 라고 말해줘!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"239 await bot.send_message(msg.channel,out_text)240 elif target[0] == "업다운":241 if onGame(user.user_id) == "업다운을":242 out_text=mention_user(user.user_id)+", 이미 플레이중인거 같은데?\n3자리 수를 생각해서 \"사잽아 ~ 맞아?\" 라고 말해줘.\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘."243 await bot.send_message(msg.channel,out_text)244 elif onGame(user.user_id)!= "" :245 out_text=mention_user(user.user_id)+", 이미 "+onGame(user.user_id)+" 플레이중인거 같은데?"246 await bot.send_message(msg.channel,out_text)247 else:248 log_append(chat_id, str(msg.content), "ud","start1")249 temp = quadra_updown.start(user.user_id)250 log_append(chat_id,str(user.user_id)+" "+str(temp), "ud","start2")251 out_text=mention_user(user.user_id)+", 좋아! 이제 시작해보자~\n \"사잽아 ~ 맞아?\" 라고 말해줘!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"252 await bot.send_message(msg.channel,out_text)253 elif target[0] == "로또":254 if onGame(user.user_id) == "로또를":255 out_text=mention_user(user.user_id)+", 이미 플레이중인거 같은데?\n1부터 35까지의 수 중 6개를 골라서 \"사잽아 ~ 맞아?\" 라고 말해줘. 예를 들면 \"사잽아 1 3 4 16 21 34 맞아?\" 느낌으로 써주면 돼!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘.\n\"사잽아 자동로또 해줘\"라고 말하면 자동으로 해볼게!."256 await bot.send_message(msg.channel,out_text)257 elif onGame(user.user_id)!= "" :258 out_text=mention_user(user.user_id)+", 이미 "+onGame(user.user_id)+" 플레이중인거 같은데?"259 await bot.send_message(msg.channel,out_text)260 else:261 if user.cash >= quadra_config.LOTTO_CHARGE :262 log_append(chat_id, str(msg.content), "lt","start1")263 temp = quadra_lotto.start(user.user_id)264 log_append(chat_id,str(user.user_id)+" "+str(temp), "lt","start2")265 out_text=mention_user(user.user_id)+", 좋아! 이제 시작해보자~\n 1부터 35까지의 수 중 6개를 골라서 \"사잽아 ~ 맞아?\" 라고 말해줘. 예를 들면 \"사잽아 1 3 4 16 21 34 맞아?\" 느낌으로 써주면 돼!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!\n\"사잽아 자동로또 해줘\"라고 말하면 자동으로 해볼게!."266 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+", 로또 구매 영수증이야!",colour=discord.Colour.blue())267 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)268 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")269 past_cash = user.cash270 user.mody(cash = (-1)*quadra_config.LOTTO_CHARGE)271 future_cash = user.cash272 em.add_field(name="사용전", value=str(past_cash), inline=True)273 em.add_field(name="비용", value="1000", inline=True)274 em.add_field(name="사용후", value=str(future_cash), inline=True)275 await bot.send_message(msg.channel,out_text,embed = em)276 else:277 log_append(chat_id,str(user.user_id)+" don't have enough money", "lt","nocs")278 out_text=mention_user(user.user_id)+", 로또를 하려면 1000원이 필요해!"279 await bot.send_message(msg.channel,out_text)280 else:281 log_append(chat_id, str(msg.content), "d_do",0)282 if target[0] in quadra_search_vocab.dis_list: 283 out_text=mention_user(user.user_id)+", "+random.choice(quadra_dialog_list.dialog_dis_do)284 await bot.send_message(msg.channel,out_text)285 user.mody(love = 2,love_time = True, exp = 5, exp_time = True)286 elif target[0] in quadra_search_vocab.adult_list:287 out_text=mention_user(user.user_id)+", "+random.choice(quadra_dialog_list.dialog_hentai_do)288 await bot.send_message(msg.channel,out_text)289 inc = - 10 - 5*(quadra_user_module.MAX_LOVE - quadra_user_module.MIN_LOVE - user.love) / (quadra_user_module.MAX_LOVE-quadra_user_module.MIN_LOVE)290 user.mody(love = inc, exp = 1, exp_time = True)291 else:292 out_text=mention_user(user.user_id)+", 미안. 뭘 하자는건지 모르겠어."293 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)294 await bot.send_message(msg.channel,out_text)295async def game_prog(msg,user):296 chat_id = msg.channel.id297 log_append(chat_id, str(msg.content), "gm","prog")298 game_name = onGame(user.user_id)299 if game_name == "야구게임을":300 target = re.search('^사잽아 ((?:(?! 맞아\?).)*) 맞아\?', str(msg.content))301 target = target.groups()302 if len(target[0]) != 3:303 log_append(chat_id,"you have to give answer 000 ~ 999", "bb","p_e1")304 out_text = mention_user(user.user_id)305 out_text+=", 혹시 하는말인데, 수는 3자리로 써야해. 까먹은건 아니지?\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"306 await bot.send_message(msg.channel,out_text)307 else:308 data = quadra_baseball.check(user.user_id)309 temp_bool = quadra_baseball.check_equal(int(target[0]))310 if temp_bool:311 result = quadra_baseball.gameManager(int(target[0]),int(data[0]))312 data[0] = int(data[0])313 if result[0] == 3:314 log_append(chat_id,"answer is "+str(data[0]), "bb","p_cor")315 out_text=mention_user(user.user_id)+", 정답이야! "+str(int(data[1])+1)+"번만에 맞췄는걸!"316 quadra_baseball.end(user.user_id)317 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 야구게임 결과!",colour=discord.Colour.blue())318 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)319 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")320 em.add_field(name="횟수", value=str(int(data[1])+1)+"회", inline=True)321 em.add_field(name="답안", value=target[0], inline=True)322 em.add_field(name="결과", value="게임 성공!", inline=False)323 temp_num = int(data[1])+1324 inc = 0325 if temp_num < 4 :326 inc = 100327 dif_love = 4328 elif temp_num < 6 :329 inc = 90330 dif_love = 3331 elif temp_num < 8 :332 inc = 75333 dif_love = 3334 elif temp_num < 11 :335 inc = 60336 dif_love = 2337 else:338 inc = 50339 dif_love = 1340 em.add_field(name="획득 경험치", value=str(inc), inline=False)341 await bot.send_message(msg.channel,out_text,embed = em)342 user.mody(love = dif_love, exp = inc)343 else:344 log_append(chat_id,str(result[0])+"-"+str(result[1])+", answer is "+str(data[0]), "bb","p_no")345 out_text=mention_user(user.user_id)+", 잘하고 있어! \n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"346 quadra_baseball.lose(user.user_id)347 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 야구게임 결과!",colour=discord.Colour.blue())348 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)349 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")350 strike = int(result[0])351 ball = int(result[1])352 result_view = "S "353 for i in range(0,2,1):354 if strike > 0:355 strike -= 1356 result_view += '●'357 else : result_view += '○'358 result_view += "\nB "359 for i in range(0,3,1):360 if ball > 0:361 ball -= 1362 result_view += '●'363 else : result_view += '○'364 result_view += "\n ( "+str(result[0])+" - " + str(result[1]) + " )"365 em.add_field(name="횟수", value=str(int(data[1])+1)+"회", inline=True)366 em.add_field(name="답안", value=target[0], inline=True)367 em.add_field(name="결과", value=result_view, inline=False)368 await bot.send_message(msg.channel,out_text,embed = em)369 else:370 log_append(chat_id,"there are duplication", "bb","p_e2")371 out_text = mention_user(user.user_id)372 out_text+=", 혹시 하는말인데, 각 자리수에 같은 숫자가 들어가면 안돼. 까먹은건 아니지?\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"373 await bot.send_message(msg.channel,out_text)374 elif game_name == "업다운을":375 target = re.search('^사잽아 ((?:(?! 맞아\?).)*) 맞아\?', str(msg.content))376 target = target.groups()377 if int(target[0]) < 0 or int(target[0]) > 100:378 log_append(chat_id,"you have to give answer 000 ~ 99", "ud","p_e1")379 out_text=mention_user(user.user_id)+", 혹시 하는말인데, 수는 100 미만의 자연수로 써야해. 까먹은건 아니지?\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"380 await bot.send_message(msg.channel,out_text)381 else:382 data = quadra_updown.check(user.user_id)383 result = quadra_updown.gameManager(int(target[0]),int(data[0]))384 if result == 0:385 log_append(chat_id,"answer is "+str(data[0]), "ud","p_cor")386 out_text=mention_user(user.user_id)+", 정답이야! "+str(int(data[1])+1)+"번만에 맞췄는걸!"387 quadra_updown.end(user.user_id)388 389 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 업다운 결과!",colour=discord.Colour.blue())390 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)391 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")392 em.add_field(name="회차", value=str(int(data[1])+1)+"회", inline=True)393 em.add_field(name="답안", value=str(int(target[0])), inline=True)394 em.add_field(name="결과", value="정답!", inline=False)395 temp_num = int(data[1])+1396 inc = 0397 if temp_num < 4 :398 inc = 75399 dif_love = 3400 elif temp_num < 6 :401 inc = 65402 dif_love = 3403 elif temp_num < 8 :404 inc = 60405 dif_love = 2406 else:407 inc = 50408 dif_love = 1409 em.add_field(name="획득 경험치", value=str(inc), inline=False)410 await bot.send_message(msg.channel,out_text,embed = em)411 user.mody(love = dif_love, exp = inc)412 elif result == 1:413 log_append(chat_id,"down, answer is "+str(data[0]), "ud","p_no")414 out_text=mention_user(user.user_id)+", 다운! 정답은 그거보다 낮은 수야! 이번이 "+str(int(data[1])+1)+"번째야!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"415 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 업다운 결과!",colour=discord.Colour.blue())416 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)417 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")418 em.add_field(name="회차", value=str(int(data[1])+1)+"회", inline=True)419 em.add_field(name="답안", value=str(int(target[0])), inline=True)420 em.add_field(name="결과", value="다운! (정답은 더 낮은수!)", inline=False)421 await bot.send_message(msg.channel,out_text,embed = em)422 quadra_updown.lose(user.user_id)423 elif result == -1:424 log_append(chat_id,"up, answer is "+str(data[0]), "ud","p_no")425 out_text=mention_user(user.user_id)+", 업! 정답은 그거보다 높은 수야! 이번이 "+str(int(data[1])+1)+"번째야!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"426 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 업다운 결과!",colour=discord.Colour.blue())427 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)428 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")429 em.add_field(name="회차", value=str(int(data[1])+1)+"회", inline=True)430 em.add_field(name="답안", value=str(int(target[0])), inline=True)431 em.add_field(name="결과", value="업! (정답은 더 높은수!)", inline=False)432 await bot.send_message(msg.channel,out_text,embed = em)433 quadra_updown.lose(user.user_id)434 elif game_name == "로또를":435 target = re.search('^사잽아 ((?:(?! 맞아\?).)*) 맞아\?', str(msg.content))436 target = target.groups()437 temp1 = target[0].split(" ")438 user_in = []439 swt = 0440 for i in temp1:441 user_in.append(int(i))442 if len(user_in) != 6 :443 log_append(chat_id,"you have to give answer 6 prices", "lt","p_e1")444 out_text=mention_user(user.user_id)+", 혹시 하는말인데, 로또는 6개의 수로 하는거야. 까먹은건 아니지?\n예를 들면 \"사잽아 1 3 4 16 21 34 맞아?\" 느낌으로 써주면 돼!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"445 swt = 1446 await bot.send_message(msg.channel,out_text)447 elif quadra_lotto.check_equal(user_in) == False:448 log_append(chat_id,"there are duplicated", "lt","p_e2")449 out_text=mention_user(user.user_id)+", 혹시 하는말인데, 각각의 수는 달라야 해.\n예를 들면 \"사잽아 1 3 4 16 21 34 맞아?\" 느낌으로 써주면 돼!\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"450 swt = 1451 await bot.send_message(msg.channel,out_text)452 else:453 for i in user_in:454 if i < 1 or i > 35:455 swt = 1456 log_append(chat_id,"you have to give answer 1 ~ 35", "lt","p_e3")457 out_text=mention_user(user.user_id)+", 혹시 하는말인데, 각각의 번호는 1~35 중의 수로 써야해. 까먹은건 아니지?\n그만하고 싶다면 \"사잽아 그만할래\"라고 말해줘!"458 await bot.send_message(msg.channel,out_text)459 if swt == 0:460 data = quadra_lotto.check(user.user_id)461 result = quadra_lotto.gameManager(user_in,data[0],data[1])462 user_in_text = ""463 for i in user_in:464 user_in_text += str(i)+" "465 text2 = mention_user(user.user_id)+", "466 text = ""467 for i in data[0]:468 text += str(i)+" "469 comp_in_text = text+": "+str(data[1])470 log_append(chat_id,"rank "+str(result)+", answer is "+text+": "+str(data[1]), "lt","p_cor")471 dif_cash = 0472 dif_love = 0473 dif_exp = 0474 if result == 1:475 text2 += "1등이네! 축하해!! 8,145,060 분의 1의 확률인데, 너무 대단한걸?"476 dif_love = 10477 dif_exp = 100478 dif_cash = 2500000000479 elif result == 2:480 text2 += "2등이야. 1등이 아니라 아쉽겠지만, 그래도 축하해!"481 dif_love = 5482 dif_exp = 50483 dif_cash = 10000000484 elif result == 3:485 text2 += "3등. 이정도면 꽤나 운이 좋은걸?"486 dif_love = 4487 dif_exp = 25488 dif_cash = 3000000489 elif result == 4:490 text2 += "4등. 733명 중 한명. 축하해."491 dif_love = 3492 dif_exp = 25493 dif_cash = 50000494 elif result == 5:495 dif_love = 2496 dif_exp = 25497 dif_cash = 5000498 text2 += "5등. 45명중의 한명이야. 그래도 본전은 뽑았을려나?"499 else: text2 += "지나친 도박은 좋지 않다구. 결국 다 잃어버리잖아.."500 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+" 의 로또 결과!",colour=discord.Colour.blue())501 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)502 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")503 em.add_field(name="방식",value="수동",inline=True)504 if result <= 5: em.add_field(name="등수",value=str(result)+"등",inline=True)505 else : em.add_field(name="등수",value="--",inline=True)506 em.add_field(name="당첨금",value=str(dif_cash)+" 원",inline=False)507 em.add_field(name="플레이어", value=user_in_text, inline=False)508 em.add_field(name="당첨번호", value=comp_in_text, inline=False)509 await bot.send_message(msg.channel,text2,embed = em)510 quadra_lotto.end(user.user_id)511 user.mody(love = dif_love, exp = dif_exp, cash = dif_cash)512 else: 513 log_append(chat_id,"there are no game playing", "gm","p_no")514 out_text=mention_user(user.user_id)+", 게임을 안하고 있는것같은데?"515 await bot.send_message(msg.channel,out_text)516async def game_end(msg,user):517 chat_id = msg.channel.id518 log_append(chat_id, str(msg.content), "bb","end")519 out_text = mention_user(user.user_id)+", "520 game_name = onGame(user.user_id)521 if game_name == "야구게임을":522 data = quadra_baseball.check(user.user_id)523 data[0] = int(data[0])524 log_append(chat_id,"answer is "+str(data[0]), "bb","end2")525 out_text += "야구게임을 그만하려고? 하는수없지. 정답은 "+str(data[0])+"이었고, 너는 "+str(data[1])+"번 시도했어!"526 quadra_baseball.end(user.user_id)527 elif game_name == "업다운을":528 data = quadra_updown.check(user.user_id)529 log_append(chat_id,"answer is "+str(data[0]), "ud","end2")530 out_text += "업다운을 그만하려고? 하는수없지. 정답은 "+str(data[0])+"이었고, 너는 "+str(data[1])+"번 시도했어!"531 quadra_updown.end(user.user_id)532 elif game_name == "로또를":533 data = quadra_lotto.check(user.user_id)534 text = ""535 for i in data[0]:536 text += str(i)+" "537 log_append(chat_id,"answer is "+text+": "+str(data[1]), "lt","p_cor")538 text2 = " 정답은 "+text+" 에 보너스번호 "+str(data[1])+" 이었어!"539 log_append(chat_id,"answer is "+str(data[0]), "lt","end2")540 out_text += "로또를 그만하려고? 하는수없지."+text2541 quadra_lotto.end(user.user_id)542 else:543 log_append(chat_id,str(user.user_id)+" isn't playing baseball", "gm","e_e")544 out_text += "애초에 안하고 있었던 것 같은데.. 게임을 하고 싶다면 먼저 \"사잽아 (게임이름) 하자\" 라고 말해줘!"545 await bot.send_message(msg.channel,out_text)546async def get_supply(msg,user):547 chat_id = msg.channel.id548 log_append(chat_id, str(msg.content), "bb","end")549 if user.canSupply():550 out_text = mention_user(user.user_id)+", "+user.supply_text()551 inc_array = quadra_config.SUPPLY_ARRAY552 past_cash = user.cash553 inc = inc_array[user.love_level()-1]554 swt = 0555 if user.cash + inc > quadra_user_module.CASH_SOFTCAP:556 if user.cash > quadra_user_module.CASH_SOFTCAP: swt = 2557 else: swt = 1558 if swt == 0 : user.mody(cash = inc, cash_time=True)559 elif swt == 1 : user.mody(cash = quadra_user_module.CASH_SOFTCAP - user.cash, cash_time=True)560 if swt <= 1:561 future_cash = user.cash562 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+", 지원금 수령 완료!",colour=discord.Colour.blue())563 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)564 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")565 em.add_field(name="수령전", value=str(past_cash), inline=True)566 em.add_field(name="지원금", value=str(inc), inline=True)567 em.add_field(name="수령후", value=str(future_cash), inline=True)568 await bot.send_message(msg.channel,out_text,embed = em)569 else:570 out_text = mention_user(user.user_id)+", 미안해. 너무 돈을 많이 가지고 있는 것 같아."571 em = discord.Embed(title=msg.author.name+"#"+str(msg.author.discriminator)+", 지원금 수령 불가",colour=discord.Colour.blue())572 if msg.author.avatar_url: em.set_thumbnail(url=msg.author.avatar_url)573 else : em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")574 em.add_field(name="수령전", value=str(past_cash), inline=True)575 em.add_field(name="지원금", value="0", inline=True)576 em.add_field(name="수령후", value=str(past_cash), inline=True)577 await bot.send_message(msg.channel,out_text,embed = em)578 else:579 out_text = mention_user(user.user_id)+", 내일 다시 와줘!"580 await bot.send_message(msg.channel,out_text)581 582async def searching(msg,user,perm):583 chat_id = msg.channel.id584 target = re.search('^사잽아 (?:((?:(?!에서).)*)에서 )?((?:(?! (알려줘|찾아줘)).)*) (알려줘|찾아줘)', str(msg.content))585 target = target.groups()586 if target[0] == '스팀':587 search_target = target[1].lower()588 term_switch = 0589 game_dict = quadra_game_list.game_synonym.items()590 for i in game_dict :591 if search_target in i[1]:592 term_switch = 1593 game_real_name = i[0]594 if search_target == i[0]:595 term_switch = 1596 game_real_name = i[0]597 if term_switch == 0:598 log_append(chat_id, str(msg.content), "sch", "g_e")599 text="미안해. 무슨 게임인지 잘 몰라서 대신 검색해줄게! ( " + quadra_search_list.search_engine["스팀"] + url_encode(target[1]) + " )"600 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)601 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)602 else : 603 log_append(chat_id, str(msg.content), "sch", "g")604 game_target = quadra_game_list.game_number[game_real_name]605 if game_target[0] == 0:606 text="혹시 이 게임 찾으려는거 맞아? ( " + quadra_game_list.steam_shop+game_target[1] + " )"607 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)608 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)609 else :610 text=game_target[0]+" ( " + quadra_game_list.steam_shop+game_target[1] + " )"611 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)612 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)613 elif target[0] in quadra_search_list.search_engine:614 if target[1] in quadra_search_vocab.adult_list:615 log_append(chat_id, str(msg.content), "sch", "ad")616 text="변태.. 이런거까지 찾아줘야해? ( " + quadra_search_list.search_engine[target[0]] + url_encode(target[1]) + " )"617 inc = - 5 - 5*(quadra_user_module.MAX_LOVE - quadra_user_module.MIN_LOVE - user.love) / (quadra_user_module.MAX_LOVE-quadra_user_module.MIN_LOVE)618 user.mody(love = inc, exp = 5, exp_time = True)619 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)620 elif target[1] in quadra_search_vocab.dis_list:621 log_append(chat_id, str(msg.content), "sch", "dis")622 text="... 이런걸 생각중이라면 그만둬. ..내가 너랑 함께 있어줄테니까. ( " + quadra_search_list.search_engine[target[0]] + url_encode(target[1]) + " )"623 user.mody(love = 2,love_time = True, exp = 5, exp_time = True)624 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)625 elif target[1] in quadra_search_vocab.wonder_list:626 log_append(chat_id, str(msg.content), "sch", "won")627 text=quadra_search_vocab.wonder_list[target[1]] + " ( " + quadra_search_list.search_engine[target[0]] + url_encode(target[1]) + " )"628 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)629 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)630 else:631 log_append(chat_id, str(msg.content), "sch", 0)632 text="이거 찾으려는거 맞지? ( " + quadra_search_list.search_engine[target[0]] + url_encode(target[1]) + " )"633 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)634 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)635 elif target[1] in quadra_search_list.hentai_url:636 log_append(chat_id, str(msg.content), "sch", "d_ad")637 text="너는 정말 최악의 변태구나.. 자, 여깄어. ( " + quadra_search_list.hentai_url[target[1]] + " )"638 inc = - 5 - 5*(quadra_user_module.MAX_LOVE - quadra_user_module.MIN_LOVE - user.love) / (quadra_user_module.MAX_LOVE-quadra_user_module.MIN_LOVE)639 user.mody(love = inc, exp = 5, exp_time = True)640 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)641 elif target[1] in quadra_search_list.direct_url:642 log_append(chat_id, str(msg.content), "sch", "d")643 text="거기라면 나도 알고있어! 바로 보내줄께! ( " + quadra_search_list.direct_url[target[1]] + " )"644 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)645 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)646 elif target[0] == "겔부루":647 if perm >= 2 :648 log_append(chat_id, str(msg.content), "sch", "g")649 temp_pid = str(random.randrange(0,1000))650 if target[1] == "아무거나":651 temp_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&pid="+temp_pid+"&json=1"652 tag_raw = "아무거나"653 elif target[1] == "야한거":654 temp_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&pid="+temp_pid+"&tags=rating:explicit&json=1"655 tag_raw = "야한거"656 elif target[1] == "안야한거":657 temp_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&pid="+temp_pid+"&tags=rating:safe&json=1"658 tag_raw = "안야한거"659 else:660 tag_list = target[1].split(" ")661 tag_raw = ""662 for i in range(0,len(tag_list),1):663 if tag_list[i] == "야한거": tag_list[i] = "rating:explicit"664 elif tag_list[i] == "안야한거": tag_list[i] = "rating:safe"665 if i == len(tag_list)-1 : tag_raw += tag_list[i]666 else : tag_raw += tag_list[i]+"+"667 temp_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&pid="+temp_pid+"&tags="+tag_raw+"&json=1"668 try:669 log_append(chat_id,"target : \""+ tag_raw+"\"", "sch", "g")670 r = requests.get(temp_url)671 r = r.text672 data = json.loads(r)673 file = data[0]["file_url"]674 embed=discord.Embed(title="태그:"+tag_raw)675 embed.set_image(url=file)676 log_append(chat_id,"transmit success!", "sch", "g")677 await bot.send_message(msg.channel, embed=embed)678 except Exception as ex:679 text="오류가 발생했어! 미안해."680 log_append(chat_id,"error occured!", "sch", "g")681 log_append(chat_id,ex, "sch", "g")682 if str(ex) == "list index out of range": text+=" 그 태그를 가진 그림이 충분히 없는 것 같아."683 else: text+=" 그 태그를 가진 그림이 없어!"684 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)685 else :686 log_append(chat_id, str(msg.content), "sch", "g")687 temp_pid = str(random.randrange(0,1000))688 if target[1] == "아무거나":689 temp_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&pid="+temp_pid+"&tags=rating:safe&json=1"690 tag_raw = "rating:safe"691 else:692 tag_list = target[1].split(" ")693 if "rating:safe" in tag_list:694 tag_raw = ""695 else:696 tag_raw = "rating:safe+"697 for i in range(0,len(tag_list),1):698 if i == len(tag_list)-1 : tag_raw += tag_list[i]699 else : tag_raw += tag_list[i]+"+"700 temp_url = "https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=1&pid="+temp_pid+"&tags="+tag_raw+"&json=1"701 try:702 log_append(chat_id,"target : \""+ tag_raw+"\"", "sch", "g")703 r = requests.get(temp_url)704 r = r.text705 data = json.loads(r)706 file = data[0]["file_url"]707 embed=discord.Embed(title="태그:"+tag_raw)708 embed.set_image(url=file)709 log_append(chat_id,"transmit success!", "sch", "g")710 await bot.send_message(msg.channel, embed=embed)711 except Exception as ex:712 text="오류가 발생했어! 미안해."713 log_append(chat_id,"error occured!", "sch", "g")714 log_append(chat_id,ex, "sch", "g")715 if str(ex) == "list index out of range": text+=" 그 태그를 가진 그림이 충분히 없는 것 같아."716 else: text+=" 그 태그를 가진 그림이 없어!"717 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)718 else:719 if target[1] in quadra_search_vocab.adult_list:720 log_append(chat_id, str(msg.content), "sch", "n_ad")721 text=target[1] + "라니... 변태! 이런거까지 찾아줘야해? ( " + quadra_search_list.search_engine["구글"] + url_encode(target[1]) + " )"722 inc = - 5 - 5*(quadra_user_module.MAX_LOVE - quadra_user_module.MIN_LOVE - user.love) / (quadra_user_module.MAX_LOVE-quadra_user_module.MIN_LOVE)723 user.mody(love = inc, exp = 5, exp_time = True)724 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)725 elif target[1] in quadra_search_vocab.dis_list:726 log_append(chat_id, str(msg.content), "sch", "n_dis")727 text=target[1] + "같은걸 생각중이라면 그만둬. ..내가 너랑 함께 있어줄테니까. ( " + quadra_search_list.search_engine['구글'] + url_encode( target[1]) + " )"728 user.mody(love = 2,love_time = True, exp = 5, exp_time = True)729 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)730 elif target[1] in quadra_search_vocab.wonder_list:731 log_append(chat_id, str(msg.content), "sch", "n_won")732 text=quadra_search_vocab.wonder_list[target[1]] + " ( " + quadra_search_list.search_engine['구글'] + url_encode(target[1]) + " )"733 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)734 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)735 else:736 log_append(chat_id, str(msg.content), "sch", "n")737 text="이거 찾으려는거 맞지? ( " + quadra_search_list.search_engine["구글"] + url_encode(target[1]) + " )"738 user.mody(love = 1,love_time = True, exp = 5, exp_time = True)739 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+text)740async def dialog_lone(msg,user):741 chat_id = msg.channel.id742 log_append(chat_id, str(msg.content), "d_lone",0)743 text = mention_user(user.user_id)+", "744 text += random.choice(quadra_dialog_list.dialog_lone_list)745 user.mody(love = 2,love_time = True, exp = 5, exp_time = True)746 await bot.send_message(msg.channel,text) 747async def memo_append(msg,user):748 chat_id = msg.channel.id749 log_append(chat_id, str(msg.content), "mm_add",0)750 text = mention_user(user.user_id)+", "751 target = re.search('^사잽아 ((?:(?! 기억해줘).)*) 기억해줘', str(msg.content))752 target = target.groups()753 memo_status = quadra_memo(user.user_id)754 temp_swt = memo_status.append(str(target[0]))755 if temp_swt == 0:756 text += "메모로 기록할께! "+str(memo_status.memo_num + 1)+"번째 메모야!"757 log_append(chat_id, "add success! : current num = "+str(memo_status.memo_num + 1), "mm_add",0)758 await bot.send_message(msg.channel,text)759 if temp_swt == 1:760 text += "너무 길어서 기억 못하겠어!"761 log_append(chat_id, "add failed! : string stack overflow", "mm_add",0)762 await bot.send_message(msg.channel,text)763 if temp_swt == 2:764 text += "이미 너무 많이 기억하고있어!"765 log_append(chat_id, "add failed! : capacity stack overflow", "mm_add",0)766 await bot.send_message(msg.channel,text)767 if temp_swt == 3:768 text += "이상한게 끼여있어서 못기억하겠어!"769 log_append(chat_id, "add failed! : forbidden string included", "mm_add",0)770 await bot.send_message(msg.channel,text)771async def memo_delete(msg,user):772 chat_id = msg.channel.id773 log_append(chat_id, str(msg.content), "mm_del",0)774 text = mention_user(user.user_id)+", "775 target = re.search('^사잽아 ((?:(?! 잊어줘).)*) 잊어줘', str(msg.content))776 target = target.groups()777 memo_status = quadra_memo(user.user_id)778 if target[0] == "전부":779 temp_swt = memo_status.purge()780 if temp_swt == 0:781 text += "메모를 전부 지웠어!"782 log_append(chat_id, "purge success!", "mm_del",0)783 await bot.send_message(msg.channel,text)784 if temp_swt == 1:785 text += "메모가 없어!"786 log_append(chat_id, "purge failed! : index out of range", "mm_del",0)787 await bot.send_message(msg.channel,text)788 else:789 target = (target[0].split('번'))[0]790 try : temp_swt = memo_status.delete(int(target))791 except Exception: temp_swt = 3792 if temp_swt == 0:793 text += "메모를 지웠어! "+str(memo_status.memo_num - 1)+"개의 메모가 남아있어!"794 log_append(chat_id, "del success! : current num = "+str(memo_status.memo_num - 1), "mm_del",0)795 await bot.send_message(msg.channel,text)796 if temp_swt == 1:797 text += "그정도로 많이 기억하고 있진 않아!"798 log_append(chat_id, "del failed! : capacity stack overflow", "mm_del",0)799 await bot.send_message(msg.channel,text)800 if temp_swt == 2:801 text += "그런 번호는 없다구!"802 log_append(chat_id, "del failed! : num must be at least 1", "mm_del",0)803 await bot.send_message(msg.channel,text)804 if temp_swt == 3:805 text += "뭘 잊어달라는건지 모르겠어!"806 log_append(chat_id, "del failed! : error occured", "mm_del",0)807 await bot.send_message(msg.channel,text)808async def memo_check(msg,user):809 chat_id = msg.channel.id810 log_append(chat_id, str(msg.content), "mm_ck",0)811 text = mention_user(user.user_id)+", "812 target = re.search('^사잽아 ((?:(?! 알려줘).)*) 알려줘', str(msg.content))813 target = target.groups()814 memo_status = quadra_memo(user.user_id)815 if target[0] == "전부":816 if memo_status.memo_num == 0:817 text += "기억하고 있는게 없어!"818 log_append(chat_id, "list failed! : no memo", "mm_ck",0)819 await bot.send_message(msg.channel,text)820 else :821 text += "메모를 찾았어!"822 log_append(chat_id, "list check!", "mm_ck",0)823 em = discord.Embed(title="내가 기억하고 있는 것들이야!", colour=discord.Colour.blue())824 temp_int = 1825 for i in memo_status.memo_str:826 em.add_field(name=str(temp_int)+"번", value=i, inline=False)827 log_append(chat_id,str(temp_int)+" : "+i, "mm_ck",0)828 temp_int += 1829 await bot.send_message(msg.channel,text,embed=em)830 else:831 target = (target[0].split('번'))[0]832 try : temp_swt = memo_status.check(int(target))833 except Exception: temp_swt = 3834 if temp_swt == 1:835 text += "그정도로 많이 기억하고 있진 않아!"836 log_append(chat_id, "check failed! : capacity stack overflow", "mm_ck",0)837 await bot.send_message(msg.channel,text)838 elif temp_swt == 2:839 text += "그런 번호는 없다구!"840 log_append(chat_id, "check failed! : num must be at least 1", "mm_ck",0)841 await bot.send_message(msg.channel,text)842 elif temp_swt == 3:843 text += "뭘 알려달라는건지 모르겠어!"844 log_append(chat_id, "check failed! : error occured", "mm_ck",0)845 await bot.send_message(msg.channel,text)846 else:847 text += "메모를 찾았어!"848 log_append(chat_id, "check success! : "+temp_swt, "mm_ck",0)849 em = discord.Embed(title=target+"번 메모",description=temp_swt, colour=discord.Colour.blue())850 await bot.send_message(msg.channel,text,embed=em)851async def quadra_trans(msg,user,perm):852 chat_id = msg.channel.id853 log_append(chat_id, str(msg.content), "trans",0)854 target = re.search('^사잽아 (?:((?:(?!로).)*)로 )?((?:(?! 번역해줘).)*) 번역해줘', str(msg.content))855 target = target.groups()856 translator = Translator()857 lang_dest = "ko"858 if target[0] in quadra_search_list.lang_list.keys():859 lang_dest = quadra_search_list.lang_list[target[0]]860 elif target[0]:861 lang_dest = target[0]862 try:863 asw = translator.translate(target[1],dest = lang_dest)864 em = discord.Embed(title="번역결과",description=asw.text, colour=discord.Colour.blue())865 if not(asw.dest == 'ko' or asw.dest == 'en'): em.add_field(name="발음", value=asw.pronunciation, inline=False)866 em.add_field(name="원문", value=asw.origin, inline=False)867 em.add_field(name="시작언어", value=asw.src, inline=True)868 em.add_field(name="결과언어", value=asw.dest, inline=True)869 text = mention_user(user.user_id)+", 번역을 마쳤어!"870 log_append(chat_id, "Success! : "+asw.text, "trans",0)871 await bot.send_message(msg.channel,text,embed=em)872 return 0873 except Exception as ex:874 if ex == ValueError:875 log_append(chat_id, "Cannot understand dest language.", "trans",0)876 await bot.send_message(msg.channel,mention_user(user.user_id)+", 어느 언어로 번역할지 제대로 이해못했어!")877 return 0878 else:879 log_append(chat_id, "Unknown Error : "+str(ex), "trans",0)880 await bot.send_message(msg.channel,mention_user(user.user_id)+", 미안해! 번역이 잘 안돼..")881 return 0882async def general_system(msg,user,perm):883 while(True):884 if msg.content == "사잽아 도와줘":885 await version(msg,user,"main",bot)886 break887 re_target = re.search('^사잽아 ((?:(?! 도와줘).)*) 도와줘',msg.content)888 if re_target:889 re_target = re_target.groups()890 await version(msg,user,re_target[0],bot)891 break892 # for general usage893 if perm > 0 or (msg.channel.permissions_for(msg.author)).administrator :894 if msg.content == "사잽아 보고싶어":895 em = discord.Embed(title="Katinor, the Quadra Ears",description="Katiadea Selinor\nCharacter Illustrated by Muku, All Right Reserved.", colour=discord.Colour.blue())896 em.set_image(url="https://i.imgur.com/VyRXaJw.png")897 await bot.send_message(msg.channel,embed=em)898 break899 if msg.content == "사잽아 누구니":900 await credit_view(msg,user,bot)901 break902 if msg.content == "사잽아 저작권":903 await credit_view(msg,user,bot)904 break905 if msg.content.startswith("사잽아 이용약관"):906 await tou_view(msg,user,bot)907 break908 if msg.content == "사잽아 뭐하니":909 await lifetime(msg,user)910 break911 if msg.content == "사잽아 놀아줘":912 await lifetime(msg,user)913 break914 re_target = re.search('^사잽(아*)$',msg.content)915 if re_target:916 await lifetime(msg,user)917 break918 re_target = re.search('^사잽아 ((?:(?! 어때).)*) 어때',msg.content)919 if re_target:920 await dialog_how(msg,user)921 break922 re_target = re.search('^사잽아 ((?:(?! (해줘|할래)).)*) (해줘|할래)',msg.content)923 if re_target:924 await dialog_please(msg,user)925 break926 re_target = re.search('^사잽아 ((?:(?! 하자).)*) 하자',msg.content)927 if re_target:928 await dialog_do(msg,user)929 break930 re_target = re.search('^사잽아 ((?:(?! 맞아\?).)*) 맞아\?',msg.content)931 if re_target:932 await game_prog(msg,user)933 break934 if msg.content == "사잽아 그만할래":935 await game_end(msg,user)936 break937 if msg.content == "사잽아 용돈줘":938 await get_supply(msg,user)939 break940 if msg.content == "사잽아 돈내놔":941 await get_supply(msg,user)942 break943 re_target = re.search('^사잽아 (?:((?:(?!에서).)*)에서 )?((?:(?! 찾아줘).)*) 찾아줘',msg.content)944 if re_target:945 await searching(msg,user,perm)946 break947 re_target = re.search('^사잽아 (?:((?:(?!로).)*)로 )?((?:(?! 번역해줘).)*) 번역해줘',msg.content)948 if re_target:949 await quadra_trans(msg,user,perm)950 break951 re_target = re.search('^사잽아 ((?:(?! 기억해줘).)*) 기억해줘',msg.content)952 if re_target:953 await memo_append(msg,user)954 break955 re_target = re.search('^사잽아 ((?:(?! 잊어줘).)*) 잊어줘',msg.content)956 if re_target:957 await memo_delete(msg,user)958 break959 re_target = re.search('^사잽아 ((?:(?! 알려줘).)*) 알려줘',msg.content)960 if re_target:961 await memo_check(msg,user)962 break963 if "외로워" in msg.content:964 await dialog_lone(msg,user)965 break966 if "안녕" in msg.content:967 await lifetime(msg,user)968 break969 if "네코" in msg.content:970 log_append(msg.channel.id, str(msg.content), "neko",0)971 result = nsfw_m.neko_search(msg.content,user,perm)972 if result[2] >= 1:973 await bot.send_message(msg.channel, embed=result[0])974 log_append(msg.channel.id, "flag name : "+result[1], "neko",0)975 else : await bot.send_message(msg.channel, mention_user(user.user_id)+", "+result[3])976 break977 if "야옹" in msg.content:978 log_append(msg.channel.id, str(msg.content), "neko",0)979 result = nsfw_m.neko_search(msg.content,user,perm)980 if result[2] >= 1:981 await bot.send_message(msg.channel, embed=result[0])982 log_append(msg.channel.id, "flag name : "+result[1], "neko",0)983 else : await bot.send_message(msg.channel, mention_user(user.user_id)+", "+result[3])984 break985 break986async def channel_system(msg,user,perm, user_perm):987 while(True):988 if "owner" in user_perm or "ch_admin" in user_perm:989 perm_class = server_permission(msg.server.id)990 re_target = re.search('^4ears channel help$',msg.content)991 if re_target:992 log_append(msg.channel.id, str(msg.content), "chl","help1")993 text = "start with \"4ears channel \"\n"994 text += "add : 채널에 권한을 추가합니다.\n"995 text += "del : 채널에 권한을 뺍니다.\n"996 text += "purge : 채널을 초기화합니다.\n"997 text += "stat : 현 채널의 권한을 확인합니다."998 em = discord.Embed(title="QuadraEarsBot channel manual",description=text, colour=discord.Colour.blue())999 em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")1000 await bot.send_message(msg.channel,embed=em)1001 break1002 re_target = re.search('^4ears channel add',msg.content)1003 if re_target:1004 log_append(msg.channel.id, str(msg.content), "chl","add")1005 if "-nsfw" in msg.content:1006 if perm_class.perm_check_admin("nsfw",msg.channel.id):1007 log_append(msg.channel.id, "already permissioned", "chl","add")1008 await bot.send_message(msg.channel,mention_user(user.user_id)+", 여긴 이미 허가되어있어!")1009 else:1010 perm_class.add("nsfw",msg.channel.id)1011 log_append(msg.channel.id, "permission success", "chl","add")1012 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이제 여기서 쫑긋 할께!")1013 else:1014 if perm_class.perm_check_admin("basic",msg.channel.id):1015 log_append(msg.channel.id, "already permissioned", "chl","add")1016 await bot.send_message(msg.channel,mention_user(user.user_id)+", 여긴 이미 허가되어있어!")1017 else:1018 perm_class.add("basic",msg.channel.id)1019 log_append(msg.channel.id, "permission success", "chl","add")1020 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이제 여기서 쫑긋 할께!")1021 break1022 re_target = re.search('^4ears channel del',msg.content)1023 if re_target:1024 log_append(msg.channel.id, str(msg.content), "chl","del")1025 if "-nsfw" in msg.content:1026 if perm_class.perm_check_admin("nsfw",msg.channel.id):1027 perm_class.delete("nsfw",msg.channel.id)1028 log_append(msg.channel.id, "permission delete", "chl","del")1029 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이제부터 여긴 안들을께!")1030 else:1031 log_append(msg.channel.id, "never heard", "chl","del")1032 await bot.send_message(msg.channel,mention_user(user.user_id)+", 여긴 원래부터 안듣고있었어!")1033 else:1034 if perm_class.perm_check_admin("basic",msg.channel.id):1035 perm_class.delete("basic",msg.channel.id)1036 log_append(msg.channel.id, "permission delete", "chl","del")1037 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이제부터 여긴 안들을께!")1038 else:1039 log_append(msg.channel.id, "never heard", "chl","del")1040 await bot.send_message(msg.channel,mention_user(user.user_id)+", 여긴 원래부터 안듣고있었어!")1041 break1042 re_target = re.search('^4ears channel purge',msg.content)1043 if re_target:1044 log_append(msg.channel.id, str(msg.content), "chl","pg")1045 if "-nsfw" in msg.content:1046 perm_class.delete_all("nsfw")1047 log_append(msg.channel.id, "purged", "chl","pg")1048 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이제부터 모든 채널을 안들을께!")1049 else:1050 perm_class.delete_all("basic")1051 log_append(msg.channel.id, "purged", "chl","pg")1052 await bot.send_message(msg.channel,mention_user(user.user_id)+", 이제부터 모든 채널을 안들을께!")1053 break1054 re_target = re.search('^4ears channel stat',msg.content)1055 if re_target:1056 log_append(msg.channel.id, str(msg.content), "chl","st")1057 perm_list_str = ""1058 if perm_class.perm_check("basic",msg.channel.id): perm_list_str += "basic,"1059 if perm_class.perm_check("nsfw",msg.channel.id): perm_list_str += "nsfw,"1060 em = discord.Embed(title="QuadraEarsBot channel status", colour=discord.Colour.blue())1061 em.set_thumbnail(url="https://i.imgur.com/pg7K8cQ.png")1062 em.add_field(name="basic 갯수", value=str(len(perm_class.allow_channel)), inline=True)1063 if len(perm_class.allow_nsfw) > 0 : em.add_field(name="nsfw 갯수", value=str(len(perm_class.allow_nsfw)), inline=True)1064 em.add_field(name="본채널", value=perm_list_str, inline=True)1065 await bot.send_message(msg.channel,embed=em)1066 break1067 else:1068 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 이 채널에 권한이 없어!")1069 break1070@bot.event1071async def on_ready():1072 log_append('system', 'Bot running Start', 'system',0)1073 await bot.change_presence(game=discord.Game(name='사잽아 도와줘 <-- 도움말'))1074@bot.event1075async def on_message(msg):1076 global server_sem1077 global user_sem1078 perm_rank = 01079 if msg.server:1080 if msg.server.id in server_sem:1081 return1082 else: server_sem.append(msg.server.id)1083 perm_class = server_permission(msg.server.id)1084 if perm_class.perm_check("nsfw",msg.channel.id): perm_rank = 21085 elif perm_class.perm_check("basic",msg.channel.id): perm_rank = 11086 else: perm_rank = 01087 else:1088 perm_rank = 11089 if msg.author.id in user_sem:1090 return1091 user_sem.append(msg.author.id)1092 if msg.author.bot == False :1093 said_user = quadra_user(msg.author.id)1094 author_perm = user_perm.check(msg, said_user.user_id)1095 if "user" in author_perm :1096 if msg.content.startswith("4ears admin"):1097 await admin_command(msg,said_user,perm_rank, user_perm, bot)1098 elif msg.content.startswith("4ears channel"):1099 await channel_system(msg,said_user, perm_rank, author_perm)1100 elif msg.content.startswith("사잽아"):1101 await general_system(msg,said_user, perm_rank)1102 else :1103 said_user.general_exp_process(len(msg.content))1104 else :1105 profile_name = "user_database/"+str(msg.author.id)+".txt"1106 if os.path.exists(profile_name) == True:1107 os.remove(profile_name)1108 log_append(msg.channel.id,msg.author.name+"#"+str(msg.author.discriminator)+" ("+str(msg.author.id)+" ) is bot. remained userdata has been deleted.","system",0)1109 if int(msg.author.id) != 423338258055823360 and perm_rank > 0 :1110 rand_int = random.randrange(0,100)1111 if rand_int < 1:1112 log_append(msg.channel.id,"bot msg triggered","system",0)1113 await bot.send_message(msg.channel,msg.author.name+"랑만 놀지말고 나랑도 놀아줘!")1114 if msg.server:1115 server_sem.remove(msg.server.id)1116 user_sem.remove(msg.author.id)...

Full Screen

Full Screen

quadra_admin_command.py

Source:quadra_admin_command.py Github

copy

Full Screen

...52 swt = True53 for i in ["-c","-s","-d","-g"]:54 if i in msg.content: swt = False55 if swt :56 log_append("notice_module", "option is unavailable", "adm","notice")57 await bot.send_message(msg.author,"옵션이 유효하지 않아!")58 return 059 if "-c" in msg.content:60 profile_name = "quadra_notice.txt"61 if os.path.exists(profile_name):62 fp = open(profile_name,"r")63 log_append("notice_module", "file is exist. sended to owner", "adm","notice")64 await bot.send_message(msg.author,"공지파일에 들어있는 내용이야!\n\n"+fp.read())65 fp.close()66 else:67 log_append("notice_module", "there are no notice file.", "adm","notice")68 await bot.send_message(msg.author,"공지파일이 존재하지 않아!")69 return 070 if "-s" in msg.content:71 profile_name = "quadra_notice.txt"72 fp = open(profile_name, "w")73 fp.write((msg.content.split("-s")[1])[1:])74 fp.close()75 fp = open(profile_name, "r")76 log_append("notice_module", "file is created", "adm","notice")77 await bot.send_message(msg.author,"공지파일에 들어있는 내용이야!\n\n"+fp.read())78 fp.close()79 return 080 log_append("notice_module", "check receiver", "adm","notice")81 temp_strarr = []82 target_owner = []83 dup_num = 084 for i in bot.servers:85 if i.owner in target_owner:86 temp_strarr.append((i.name, i.owner,"Duplicated"))87 dup_num += 188 else:89 temp_strarr.append((i.name, i.owner,"Saved"))90 target_owner.append(i.owner)91 del target_owner92 log_append("notice_module", "check receiver end : "+str(len(temp_strarr))+" servers, "+str(dup_num)+" dups", "adm","notice")93 if "-d" in msg.content:94 out_text = "아래 목록에 있는 사람들에게 보내질거야!\n\n"95 for i in temp_strarr:96 if i[2] == "Saved":97 out_text+= i[1].name+"#"+i[1].discriminator+" : "+i[0]98 else:99 out_text+= i[1].name+"#"+i[1].discriminator+" : "+i[0]+" *(중복됨)*"100 out_text+="\n"101 out_text+="총 "+str(len(temp_strarr)-dup_num)+" 명에게 보낼거야. "+str(dup_num)+"명은 다른 서버도 가지고 있더라구."102 await bot.send_message(msg.author,out_text)103 log_append("notice_module", "receiver list has been transmitted", "adm","notice")104 return 0105 target_str = ""106 profile_name = "quadra_notice.txt"107 if os.path.exists(profile_name):108 fp = open(profile_name,"r")109 log_append("notice_module", "file is exist. load to memory.", "adm","notice")110 target_str = fp.read()111 fp.close112 else:113 log_append("notice_module", "there are no notice file.", "adm","notice")114 await bot.send_message(msg.author,"공지파일이 존재하지 않아!")115 return 0116 117 dup_num = 0118 suc_num = 0119 err_num = 0120 log_append("notice_module", "file checked, start to send", "adm","notice")121 for i in temp_strarr:122 if i[2] == "Saved":123 try:124 await bot.send_message(i[1],target_str)125 log_append("notice_module", i[1].name+"#"+i[1].discriminator+" : "+i[0], "adm","notice")126 suc_num += 1127 except Exception as ex:128 log_append("notice_module", i[1].name+"#"+i[1].discriminator+" : "+i[0]+" :: "+str(ex), "adm","notice")129 await bot.send_message(msg.author,"[ERROR]"+i[1].name+"#"+i[1].discriminator+" : "+i[0]+" :: "+str(ex))130 err_num += 1131 else:132 log_append("notice_module", i[1].name+"#"+i[1].discriminator+" : "+i[0]+" (duplicated)", "adm","notice")133 dup_num += 1134 log_append("notice_module", "success : "+str(suc_num)+" success, "+str(dup_num)+" dups", "adm","notice")135 await bot.send_message(msg.author,str(suc_num)+"명에게 보냈어! "+str(dup_num)+"명은 다른 서버도 소유하고 있었어. "+str(err_num)+"명은 에러가 발생했어.")136 return 0137async def admin_command(msg, user, channel_perm, user_perm, bot):138 author_perm = user_perm.check(msg, user.user_id)139 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id+" ["140 for i in author_perm:141 log_text += i+", "142 log_text += "]"143 log_append(msg.channel.id,"admin panel access : "+log_text, "adm","acc")144 while(True):145 if msg.content == '4ears admin copyright':146 log_append(msg.channel.id, str(msg.content), "adm","cpy")147 if "admin" in author_perm :148 await credit_view(msg,user,bot,perm = True)149 else:150 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id151 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")152 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 권한이 없어!")153 break154 if msg.content == '4ears admin tou':155 log_append(msg.channel.id, str(msg.content), "adm","tou")156 if "admin" in author_perm :157 await tou_view(msg,user,bot,perm = True)158 else:159 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id160 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")161 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 권한이 없어!")162 break163 if msg.content == '4ears admin help':164 log_append(msg.channel.id, str(msg.content), "adm","help")165 temp_cont = admin_help("main",user,author_perm)166 await bot.send_message(msg.channel,temp_cont[0],embed=temp_cont[1])167 break168 if msg.content == '4ears admin help admin':169 log_append(msg.channel.id, str(msg.content), "adm","help")170 temp_cont = admin_help("admin",user,author_perm)171 await bot.send_message(msg.channel,temp_cont[0],embed=temp_cont[1])172 break173 if msg.content == '4ears admin help block':174 log_append(msg.channel.id, str(msg.content), "adm","help")175 temp_cont = admin_help("block",user,author_perm)176 await bot.send_message(msg.channel,temp_cont[0],embed=temp_cont[1])177 break178 if msg.content == '4ears admin help user':179 log_append(msg.channel.id, str(msg.content), "adm","help")180 temp_cont = admin_help("user",user,author_perm)181 await bot.send_message(msg.channel,temp_cont[0],embed=temp_cont[1])182 break183 if msg.content == '4ears admin help notice':184 log_append(msg.channel.id, str(msg.content), "adm","help")185 temp_cont = admin_help("notice",user,author_perm)186 await bot.send_message(msg.channel,temp_cont[0],embed=temp_cont[1])187 break188 if msg.content.startswith("4ears admin add"):189 log_append(msg.channel.id, str(msg.content), "adm","add")190 if "owner" in author_perm:191 add_list = msg.mentions192 if add_list:193 temp_s1 = 0194 temp_s2 = 0195 temp_s0 = 0196 for i in add_list:197 temp_var = user_perm.admin_add(i)198 if temp_var == 0: temp_s0 += 1199 elif temp_var == 1: temp_s1 += 1200 elif temp_var == 2: temp_s2 += 1201 user_perm.admin_save()202 temp_txt = "권한을 부여했어!"203 if temp_s0 > 0 : temp_txt += "\n"+str(temp_s0)+"명에게 권한을 부여했어!"204 if temp_s1 > 0 : temp_txt += "\n"+str(temp_s1)+"명은 이미 권한이 있어!"205 if temp_s2 > 0 : temp_txt += "\n"+str(temp_s2)+"명은 봇이야!"206 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+temp_txt)207 else: await bot.send_message(msg.channel,mention_user(user.user_id)+", 대상이 잘못된거같은데?")208 else:209 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id210 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")211 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내 주인님이 아냐!")212 break213 if msg.content.startswith("4ears admin del"):214 log_append(msg.channel.id, str(msg.content), "adm","del")215 if "owner" in author_perm:216 add_list = msg.mentions217 if add_list:218 temp_s1 = 0219 temp_s2 = 0220 temp_s0 = 0221 for i in add_list:222 temp_var = user_perm.admin_del(i)223 if temp_var == 0: temp_s0 += 1224 elif temp_var == 1: temp_s1 += 1225 elif temp_var == 2: temp_s2 += 1226 user_perm.admin_save()227 temp_txt = "권한을 회수했어!"228 if temp_s0 > 0 : temp_txt += "\n"+str(temp_s0)+"명의 권한을 회수했어!"229 if temp_s1 > 0 : temp_txt += "\n"+str(temp_s1)+"명은 애초에 권한이 없어!"230 if temp_s2 > 0 : temp_txt += "\n"+str(temp_s2)+"명은 봇이야!"231 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+temp_txt)232 else: await bot.send_message(msg.channel,mention_user(user.user_id)+", 대상이 잘못된거같은데?")233 else:234 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id235 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")236 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내 주인님이 아냐!")237 break238 if msg.content.startswith("4ears admin block"):239 log_append(msg.channel.id, str(msg.content), "bl","add")240 if "admin" in author_perm:241 add_list = msg.mentions242 if add_list:243 temp_s1 = 0244 temp_s2 = 0245 temp_s3 = 0246 temp_s4 = 0247 temp_s0 = 0248 for i in add_list:249 temp_var = user_perm.block(i,author_perm)250 if temp_var == 0: temp_s0 += 1251 elif temp_var == 1: temp_s1 += 1252 elif temp_var == 2: temp_s2 += 1253 elif temp_var == 3: temp_s3 += 1254 elif temp_var == 4: temp_s4 += 1255 user_perm.block_save()256 temp_txt = "차단을 완료했어!"257 if temp_s0 > 0 : temp_txt += "\n"+str(temp_s0)+"명을 무시할께!"258 if temp_s4 > 0 : temp_txt += "\n"+str(temp_s4)+"명은 무시할 겸 관리자도 해고했어!!"259 if temp_s3 > 0 : temp_txt += "\n"+str(temp_s3)+"명은 관리자라서 무시할 수 없어!"260 if temp_s1 > 0 : temp_txt += "\n"+str(temp_s1)+"명은 이미 무시하고있어!"261 if temp_s2 > 0 : temp_txt += "\n"+str(temp_s2)+"명은 봇이야!"262 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+temp_txt)263 else: await bot.send_message(msg.channel,mention_user(user.user_id)+", 대상이 잘못된거같은데?")264 else:265 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id266 log_append(msg.channel.id,"access denied - "+log_text, "bl","err")267 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 권한이 없어!")268 break269 if msg.content.startswith("4ears admin unblock"):270 log_append(msg.channel.id, str(msg.content), "bl","del")271 if "admin" in author_perm:272 add_list = msg.mentions273 if add_list:274 temp_s1 = 0275 temp_s2 = 0276 temp_s0 = 0277 for i in add_list:278 temp_var = user_perm.unblock(i)279 if temp_var == 0: temp_s0 += 1280 elif temp_var == 1: temp_s1 += 1281 elif temp_var == 2: temp_s2 += 1282 user_perm.block_save()283 temp_txt = "차단을 해제했어!"284 if temp_s0 > 0 : temp_txt += "\n"+str(temp_s0)+"명의 말을 다시 들을께!"285 if temp_s1 > 0 : temp_txt += "\n"+str(temp_s1)+"명은 듣고 있었어!"286 if temp_s2 > 0 : temp_txt += "\n"+str(temp_s2)+"명은 봇이야!"287 await bot.send_message(msg.channel,mention_user(user.user_id)+", "+temp_txt)288 else: await bot.send_message(msg.channel,mention_user(user.user_id)+", 대상이 잘못된거같은데?")289 else:290 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id291 log_append(msg.channel.id,"access denied - "+log_text, "bl","err")292 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 권한이 없어!")293 break294 if msg.content.startswith("4ears admin love"):295 log_append(msg.channel.id, str(msg.content), "adm","love")296 if "admin" in author_perm :297 trg_list = msg.mentions298 if len(trg_list) == 1:299 trg_id = trg_list[0].id300 trg_user = quadra_user(trg_id)301 love_stat = trg_user.love302 if "-server" in msg.content: await bot.send_message(msg.channel,mention_user(user.user_id)+"!\n"+"<@"+str(trg_id)+"> 의 친밀도는 "+str(love_stat)+" 이야!")303 else: await bot.send_message(msg.author,mention_user(user.user_id)+"!\n"+"<@"+str(trg_id)+"> 의 친밀도는 "+str(love_stat)+" 이야!")304 else: await bot.send_message(msg.channel,mention_user(user.user_id)+" 한번에 한명만 물어봐줘!")305 else:306 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id307 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")308 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 가르쳐 줄수 없어!")309 break310 if msg.content.startswith("4ears admin lovcng"):311 log_append(msg.channel.id, str(msg.content), "adm","lovcng")312 if "owner" in author_perm:313 trg_list = msg.mentions314 if len(trg_list) == 1:315 trg_id = trg_list[0].id316 trg_user = quadra_user(trg_id)317 data = str(msg.content).split(" ")318 val1 = int(data[len(data)-1])319 if "-add" in msg.content: val1 = trg_user.love + val1 320 elif "-del" in msg.content : val1 = trg_user.love - val1321 if val1 > quadra_user_module.MAX_LOVE : val1 = quadra_user_module.MAX_LOVE322 if val1 < quadra_user_module.MIN_LOVE : val1 = quadra_user_module.MIN_LOVE323 trg_user.change(love = val1)324 await bot.send_message(msg.channel,mention_user(user.user_id)+"!\n"+"<@"+str(trg_id)+"> 의 친밀도는 이제 "+str(val1)+" 이야!")325 else: await bot.send_message(msg.channel,mention_user(user.user_id)+" 한번에 한명만 물어봐줘!")326 else:327 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id328 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")329 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내 주인님이 아니야!!")330 break331 if msg.content == '4ears admin stats':332 log_append(msg.channel.id, str(msg.content), "adm","stats")333 if "admin" in author_perm:334 fp = open("quadra_server_list.txt","w")335 for i in bot.servers:336 fp.write(i.name+"\n")337 fp.close()338 text = mention_user(user.user_id)+", 현재 "+ str(len(bot.servers))+" 개의 서버에서 사용중이야! "+str(len(set(bot.get_all_members())))+" 명이 날 보고있어!"339 await bot.send_message(msg.channel,text)340 else:341 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id342 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")343 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내가 인정한 사람이 아니야!")344 break345 if msg.content.startswith('4ears admin notice'):346 log_append(msg.channel.id, str(msg.content), "adm","notice")347 if "owner" in author_perm:348 await admin_notice(msg,bot)349 else:350 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id351 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")352 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내가 인정한 사람이 아니야!")353 break354 if msg.content.startswith("4ears admin levcng"):355 log_append(msg.channel.id, str(msg.content), "adm","levcng")356 if "owner" in author_perm:357 trg_list = msg.mentions358 if len(trg_list) == 1:359 trg_id = trg_list[0].id360 trg_user = quadra_user(trg_id)361 data = str(msg.content).split(" ")362 val1 = int(data[len(data)-1])363 if "-add" in msg.content: val1 = trg_user.level + val1364 elif "-del" in msg.content: val1 = trg_user.level - val1365 if val1 < 0 : val1 = 0366 if val1 >= len(quadra_user_module.REQ_EXP) : val1 = len(quadra_user_module.REQ_EXP)367 trg_user.change(level = val1)368 await bot.send_message(msg.channel,mention_user(user.user_id)+"!\n"+"<@"+str(trg_id)+"> 의 레벨은 이제 "+str(val1)+" 이야!\n")369 else: await bot.send_message(msg.channel,mention_user(user.user_id)+" 한번에 한명만 물어봐줘!")370 else:371 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id372 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")373 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내 주인님이 아니야!!")374 break375 if msg.content.startswith("4ears admin expcng"):376 log_append(msg.channel.id, str(msg.content), "adm","expcng")377 if "owner" in author_perm:378 trg_list = msg.mentions379 if len(trg_list) == 1:380 trg_id = trg_list[0].id381 trg_user = quadra_user(trg_id)382 data = str(msg.content).split(" ")383 val1 = int(data[len(data)-1])384 if "-add" in msg.content: val1 = trg_user.exp + val1385 elif "-del" in msg.content: val1 = trg_user.exp - val1386 trg_user.change(exp = val1)387 await bot.send_message(msg.channel,mention_user(user.user_id)+"!\n"+"<@"+str(trg_id)+"> 의 경험치는 이제 "+str(val1)+" 이야!")388 else: await bot.send_message(msg.channel,mention_user(user.user_id)+" 한번에 한명만 물어봐줘!")389 else:390 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id391 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")392 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내 주인님이 아니야!!")393 break394 if msg.content.startswith("4ears admin cachcng"):395 log_append(msg.channel.id, str(msg.content), "adm","cscng")396 if "owner" in author_perm:397 trg_list = msg.mentions398 if len(trg_list) == 1:399 trg_id = trg_list[0].id400 data = str(msg.content).split(" ")401 val1 = int(data[len(data)-1])402 trg_user = quadra_user(trg_id)403 if "-add" in msg.content: val1 = trg_user.cash + val1404 elif "-del" in msg.content: val1 = trg_user.cash - val1405 trg_user.change(cash = val1)406 await bot.send_message(msg.channel,mention_user(user.user_id)+"!\n"+"<@"+str(trg_id)+"> 의 돈은 이제 "+str(val1)+" 이야!")407 else: await bot.send_message(msg.channel,mention_user(user.user_id)+" 한번에 한명만 물어봐줘!")408 else:409 log_text = msg.author.name+"#"+msg.author.discriminator+" : "+msg.author.id410 log_append(msg.channel.id,"access denied - "+log_text, "adm","err")411 await bot.send_message(msg.channel,mention_user(user.user_id)+", 너는 내 주인님이 아니야!!")412 break413 if msg.content.startswith("4ears admin memo"):414 log_append(msg.channel.id, str(msg.content), "adm","mm")415 if "admin" in author_perm or "ch_admin" in author_perm :416 trg_list = msg.mentions417 if len(trg_list) == 1:418 text = mention_user(user.user_id)+", "419 trg_id = trg_list[0].id420 memo_status = quadra_memo(trg_id)421 if memo_status.memo_num == 0:422 text += mention_user(trg_id)+"는 메모를 쓴게 없어!"423 log_append(msg.channel.id, "list failed! : no memo", "adm","mm")424 await bot.send_message(msg.channel,text)425 else :426 text += mention_user(trg_id)+"의 메모를 찾았어!"427 log_append(msg.channel.id, "list check!", "adm","mm")428 em = discord.Embed(title="내가 기억하고 있는 것들이야!", colour=discord.Colour.blue())429 temp_int = 1430 for i in memo_status.memo_str:431 em.add_field(name=str(temp_int)+"번", value=i, inline=False)432 log_append(msg.channel.id,str(temp_int)+" : "+i, "mm_ck",0)433 temp_int += 1434 await bot.send_message(msg.channel,text,embed=em) 435 break...

Full Screen

Full Screen

ansyrun.py

Source:ansyrun.py Github

copy

Full Screen

...20 global_env.MainWindow.ableAllButton(False)21 self.append_signal.connect(append_signal_do)22 self.status_signal.connect(status_signal_do)23 self.end_signal.connect(end_signal_do)24 def log_append(self, text):25 self.append_signal.emit(text)26 def run(self):27 try:28 name_id = random.randint(100000000000, 999999999999)29 infoList = []30 mainNameDir = os.path.join(self.maindir, str(name_id))31 self.log_append("开始获取视频信息")32 for i in range(len(self.audiopathlist)):33 audiopath = self.audiopathlist[i]34 xmlpath = self.xmlpathlist[i]35 title = self.titlelist[i]36 try:37 video_duration = action_def.get_video_duration(audiopath)38 if video_duration <= 0:39 raise Exception("无法获取视频时长")40 video_duration = int(1000 * video_duration)41 except Exception as e:42 self.log_append("未获取到" + audiopath + "的时长")43 self.log_append(str(e))44 video_duration = 144000045 try:46 video_size = action_def.get_fileSize(audiopath)47 if video_size <= 0:48 raise Exception("无法获取视频大小")49 except Exception as e:50 self.log_append("未获取到" + audiopath + "的大小")51 self.log_append(str(e))52 video_size = 39110618053 try:54 danmu_len = action_def.get_xml_d_num(xmlpath)55 except Exception as e:56 self.log_append("未获取到" + xmlpath + "的弹幕数量")57 self.log_append(str(e))58 danmu_len = 059 print(video_duration)60 print(video_size)61 print(danmu_len)62 info_dict = {}63 info_dict["page"] = i + 164 info_dict["audiopath"] = audiopath65 info_dict["xmlpath"] = xmlpath66 info_dict["title"] = title67 info_dict["video_duration"] = video_duration68 info_dict["video_size"] = video_size69 info_dict["danmu_len"] = danmu_len70 info_dict["cid"] = name_id + i71 infoList.append(info_dict)72 self.log_append("视频信息获取完毕")73 self.log_append("开始写入配置文件")74 os.makedirs(mainNameDir)75 for i in infoList:76 temp_json = json.loads(global_env.temp_json_text)77 temp_json["avid"] = name_id78 temp_json["downloaded_bytes"] = i["video_size"]79 temp_json["total_bytes"] = i["video_size"]80 temp_json["danmaku_count"] = i["danmu_len"]81 temp_json["title"] = self.name82 temp_json["total_time_milli"] = i["video_duration"]83 # temp_json["type_tag"] = i[]84 temp_json["page_data"]["cid"] = i["cid"]85 temp_json["page_data"]["page"] = i["page"]86 temp_json["page_data"]["part"] = i["title"]87 os.makedirs(os.path.join(mainNameDir, str(i["page"])))88 with open(os.path.join(mainNameDir, str(i["page"]), "entry.json"), "w", encoding='utf-8') as f:89 json.dump(temp_json, f, ensure_ascii=False)90 self.log_append("写入配置文件完成")91 self.log_append("开始移入视频、弹幕")92 for i in infoList:93 self.log_append(i["audiopath"])94 s_copy(i["audiopath"], os.path.join(mainNameDir, str(i["page"]), "lua.flv.bapi.2_remux.mp4"))95 s_copy(i["xmlpath"], os.path.join(mainNameDir, str(i["page"]), "danmaku.xml"))96 self.log_append("移入视频、弹幕完成")97 self.log_append("成功!")98 except Exception as e:99 print(e.args)100 print(str(e))101 print(repr(e))102 self.log_append(str(e))103 self.end_signal.emit()104def status_signal_do(text):105 global_env.mainWin.statusbar.showMessage(text)106def append_signal_do(text):107 textBrowser = global_env.MainWindow.tipstextBrowser108 textBrowser.insertPlainText(text + "\n")109 textBrowser.moveCursor(textBrowser.textCursor().End)110def end_signal_do():...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful