Best Python code snippet using tempest_python
_bot.py
Source:_bot.py
...87 text=dedent(message_text),88 parse_mode='HTML',89 reply_markup=get_subscribtion_menu()90 )91 context.bot.delete_message(92 chat_id=update.message.chat_id,93 message_id=update.message.message_id94 )95 return 'CONFIRM_MENU'96def confirm_menu_handler(context, update):97 query = update.callback_query98 if query.data == 'no_mail':99 context.bot.send_message(100 chat_id=query.message.chat_id,101 text=f'СпаÑибо за подÑвеÑждение ÑегиÑÑÑаÑии. ÐÑ ÑÐ°Ð´Ñ Ð±Ñдем видеÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',102 reply_markup=get_main_menu(query.message.chat_id)103 )104 context.bot.delete_message(105 chat_id=query.message.chat_id,106 message_id=query.message.message_id107 )108 return 'MAIN_MENU'109 elif query.data == 'mail':110 message_text = f'''111 СпаÑибо за подÑвеÑждение ÑегиÑÑÑаÑии. 112 113 ÐÐ»Ñ Ð·Ð°Ð²ÐµÑÑÐµÐ½Ð¸Ñ ÑегиÑÑÑаÑии введиÑе Ð²Ð°Ñ email114 '''115 context.bot.send_message(116 chat_id=query.message.chat_id,117 text=dedent(message_text),118 )119 context.bot.delete_message(120 chat_id=query.message.chat_id,121 message_id=query.message.message_id122 )123 return 'WAIT_EMAIL'124def wait_email_handler(context, update):125 chat_id = update.message.chat.id126 meetuper = Meetuper.objects.get(chat_id=chat_id)127 meetuper.email = update.message.text128 meetuper.save()129 meetup = MeetupProgram.objects.get(current=True)130 context.bot.send_message(131 chat_id=chat_id,132 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе <b><i>"{meetup.title}"</i></b>.',133 parse_mode='HTML',134 reply_markup=get_main_menu(chat_id)135 )136 context.bot.delete_message(137 chat_id=chat_id,138 message_id=update.message.message_id - 1139 )140 return 'MAIN_MENU'141def main_menu_handler(context, update):142 query = update.callback_query143 if query.data == 'meetup':144 meetup = MeetupProgram.objects.get(current=True)145 context.bot.send_message(146 chat_id=query.message.chat_id,147 text=f'ÐожеÑе ознакомиÑÑÑÑ Ñ Ð¿ÑогÑаммой миÑапа <b><i>"{meetup.title}"</i></b>.'148 f' или задаÑÑ Ð²Ð¾Ð¿ÑÐ¾Ñ Ð»ÑÐ±Ð¾Ð¼Ñ ÑпикеÑÑ',149 parse_mode='HTML',150 reply_markup=get_meetup_description_menu()151 )152 context.bot.delete_message(153 chat_id=query.message.chat_id,154 message_id=query.message.message_id155 )156 return 'MEETUP_DESCRIPTION_MENU'157 elif query.data == 'communication':158 message_text = '''159 ÐдеÑÑ Ð²Ñ ÑможеÑе заполниÑÑ Ð°Ð½ÐºÐµÑÑ Ð¾ Ñебе и пообÑаÑÑÑÑ Ñ Ð´ÑÑгими ÑÑаÑÑниками миÑапа.160 '''161 context.bot.send_message(162 chat_id=query.message.chat_id,163 text=dedent(message_text),164 reply_markup=get_communication_menu(query.message.chat_id)165 )166 context.bot.delete_message(167 chat_id=query.message.chat_id,168 message_id=query.message.message_id169 )170 return 'COMMUNICATION_MENU'171 elif query.data == 'donate':172 context.bot.send_message(173 chat_id=query.message.chat_id,174 text=f'ÐÐ°Ñ Ð²ÐºÐ»Ð°Ð´ в наÑе ÑазвиÑие Ð¿Ð¾Ð·Ð²Ð¾Ð»Ð¸Ñ Ð½Ð°Ð¼ пÑодолжаÑÑ ÑабоÑÑ Ð½Ð°Ð´ кÑÑÑÑми миÑапами',175 reply_markup=get_donate_menu()176 )177 context.bot.delete_message(178 chat_id=query.message.chat_id,179 message_id=query.message.message_id180 )181 return 'DONATE'182 elif query.data == 'signup':183 message_text = '''184ЧÑÐ¾Ð±Ñ ÑÑаÑÑ ÑпикеÑом на ÑледÑÑÑем миÑапе, нам нÑжно полÑÑиÑÑ Ð¾Ñ ÐÐ°Ñ Ð½ÐµÐ¼Ð½Ð¾Ð³Ð¾ оÑÐµÐ½Ñ Ð²Ð°Ð¶Ð½Ð¾Ð¹ Ð´Ð»Ñ Ð½Ð°Ñ Ð¸Ð½ÑоÑмаÑии.185ÐÐ»Ñ Ð½Ð°Ñала введиÑе ÑÐµÐ¼Ñ Ð´Ð¾ÐºÐ»Ð°Ð´Ð°, Ñ ÐºÐ¾ÑоÑой ÐÑ Ñ
оÑиÑе вÑÑÑÑпиÑÑ.186 '''187 context.bot.send_message(188 chat_id=query.message.chat_id,189 text=dedent(message_text),190 reply_markup=get_back_menu()191 )192 context.bot.delete_message(193 chat_id=query.message.chat_id,194 message_id=query.message.message_id195 )196 return 'SIGNUP'197 elif query.data == 'subscribe':198 message_text = '''199ÐÑ Ð¿Ð¾Ð´Ð¿Ð¸ÑалиÑÑ Ð½Ð° ÑÑаÑÑие в ÑледÑÑÑем миÑапе.200 '''201 meetuper = Meetuper.objects.get(chat_id=query.message.chat_id)202 meetuper.is_subcribed_next_meetup = True203 meetuper.save()204 context.bot.send_message(205 chat_id=query.message.chat_id,206 text=dedent(message_text),207 reply_markup=get_main_menu(query.message.chat_id)208 )209 context.bot.delete_message(210 chat_id=query.message.chat_id,211 message_id=query.message.message_id212 )213 return 'MAIN_MENU'214 elif query.data == 'questions':215 message_text = f'''216ÐопÑоÑÑ Ð¾Ñ ÑÑаÑÑников миÑапа:217{get_questions(query.message.chat_id)}218'''219 context.bot.send_message(220 chat_id=query.message.chat_id,221 text=message_text,222 reply_markup=get_back_menu()223 )224 context.bot.delete_message(225 chat_id=query.message.chat_id,226 message_id=query.message.message_id227 )228 return 'QUESTIONS'229 elif query.data == 'back':230 context.bot.send_message(231 chat_id=query.message.chat_id,232 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',233 reply_markup=get_main_menu(query.message.chat_id)234 )235 context.bot.delete_message(236 chat_id=query.message.chat_id,237 message_id=query.message.message_id238 )239 return 'MAIN_MENU'240def signup_handler(context, update):241 query = update.callback_query242 if query and query.data == 'back':243 context.bot.send_message(244 chat_id=query.message.chat_id,245 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',246 reply_markup=get_main_menu(query.message.chat_id)247 )248 context.bot.delete_message(249 chat_id=query.message.chat_id,250 message_id=query.message.message_id251 )252 return 'MAIN_MENU'253 message_text = '''254ЧÑÐ¾Ð±Ñ ÑзнаÑÑ Ð¾ ÐÐ°Ñ Ð¿Ð¾Ð±Ð¾Ð»ÑÑе, а поÑом ÑаÑÑказаÑÑ Ð½Ð°Ñим ÑÑаÑÑникам о кÑÑÑом докладÑике, нам нÑжно ÐаÑе ÑезÑме.255ÐÑиÑлиÑе нам его в виде лÑбого докÑменÑа.256ÐÑли ÐÑ Ð½Ðµ можеÑе ÑейÑÐ°Ñ Ð¾ÑпÑавиÑÑ Ð½Ð°Ð¼ ÑезÑме - пÑоÑÑо пÑиÑлиÑе его в ÑÐ°Ñ Ð¿Ð¾Ð·Ð¶Ðµ, и Ð¼Ñ Ð¾Ð±ÑзаÑелÑно его Ñвидим.257 '''258 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)259 meetuper.topics.create(260 title=update.message.text,261 )262 Speaker.objects.get_or_create(263 participant=meetuper,264 )265 context.bot.send_message(266 chat_id=update.message.chat_id,267 text=dedent(message_text),268 reply_markup=get_back_menu()269 )270 context.bot.delete_message(271 chat_id=update.message.chat_id,272 message_id=update.message.message_id - 1273 )274 context.bot.delete_message(275 chat_id=update.message.chat_id,276 message_id=update.message.message_id277 )278 return 'MAIN_MENU'279def download_cv(url, filename):280 if not os.path.exists(f'{settings.MEDIA_ROOT}'):281 os.makedirs(f'{settings.MEDIA_ROOT}')282 local_filename = f'{settings.MEDIA_ROOT}/' + filename283 response = requests.get(url)284 response.raise_for_status()285 with open(local_filename, 'wb') as f:286 for chunk in response.iter_content(chunk_size=1024):287 if chunk:288 f.write(chunk)289 return local_filename290def cv_handler(update, context):291 chat_id = update.message.chat_id292 filename = f'CV-{chat_id}.' + update.message.document.file_name.split('.')[-1]293 file_info = context.bot.get_file(update.message.document.file_id)294 cv = download_cv(file_info.file_path, filename)295 meetuper = Meetuper.objects.get(chat_id=chat_id)296 with open(cv, 'rb') as f:297 meetuper.cv.save(filename, File(f), False)298 meetuper.save()299 context.bot.send_message(300 chat_id=chat_id,301 text=f'Ðак ÑолÑко оÑганизаÑоÑÑ Ð¾Ð´Ð¾Ð±ÑÑÑ ÐÐ°Ñ Ð² каÑеÑÑве докладÑика Ð¼Ñ Ð¾Ð±ÑзаÑелÑно об ÑÑом ÑообÑим',302 reply_markup=get_main_menu(chat_id)303 )304 context.bot.delete_message(305 chat_id=chat_id,306 message_id=update.message.message_id - 1307 )308 context.bot.delete_message(309 chat_id=chat_id,310 message_id=update.message.message_id311 )312 return 'MAIN_MENU'313def communication_menu_handler(context, update):314 query = update.callback_query315 if query.data == 'main_menu':316 context.bot.send_message(317 chat_id=query.message.chat_id,318 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',319 reply_markup=get_main_menu(query.message.chat_id)320 )321 context.bot.delete_message(322 chat_id=query.message.chat_id,323 message_id=query.message.message_id324 )325 return 'MAIN_MENU'326 elif query.data == 'form':327 context.bot.send_message(328 chat_id=query.message.chat_id,329 text=f'ÐведиÑе ваÑе имÑ',330 )331 context.bot.delete_message(332 chat_id=query.message.chat_id,333 message_id=query.message.message_id334 )335 return 'FIRSTNAME'336 elif query.data == 'communicate':337 meetupers_id = [338 meetuper.chat_id for meetuper in Meetuper.objects.339 filter(is_open_for_communication=True).340 exclude(chat_id=query.message.chat_id)341 ]342 if len(meetupers_id) >= 1:343 communicate_id = random.choice(meetupers_id)344 meetuper = Meetuper.objects.get(chat_id=communicate_id)345 message_text = f'''ÐÑ Ð¼Ð¾Ð¶ÐµÑе пообÑаÑÑÑÑ Ñ 346<b><i>{meetuper.firstname} {meetuper.lastname}</i></b>.347 348{meetuper.firstname} ÑÑÑдиÑÑÑ Ð² {meetuper.organization} на должноÑÑи {meetuper.position}349 350Ðли можеÑе зайÑи ÑÑда попозже, Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÐºÑо-Ñо еÑе бÑÐ´ÐµÑ Ð³Ð¾Ñов пообÑаÑÑÑÑ.351 '''352 context.bot.send_message(353 chat_id=query.message.chat_id,354 text=dedent(message_text),355 parse_mode='HTML',356 reply_markup=get_contact_menu(communicate_id)357 )358 else:359 message_text = '''360ÐÐµÑ Ð´ÑÑгиÑ
ÑÑаÑÑников миÑапа, коÑоÑÑе могÑÑ Ñ Ðами пообÑаÑÑÑÑ.361 362ÐаÑ
одиÑе позже.363 '''364 context.bot.send_message(365 chat_id=query.message.chat_id,366 text=dedent(message_text),367 parse_mode='HTML',368 reply_markup=get_contact_menu()369 )370 context.bot.delete_message(371 chat_id=query.message.chat_id,372 message_id=query.message.message_id373 )374 return 'CHAT'375def chat_handler(context, update):376 query = update.callback_query377 if query.data == 'main_menu':378 context.bot.send_message(379 chat_id=query.message.chat_id,380 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',381 reply_markup=get_main_menu(query.message.chat_id)382 )383 context.bot.delete_message(384 chat_id=query.message.chat_id,385 message_id=query.message.message_id386 )387 return 'MAIN_MENU'388def firstname_handler(context, update):389 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)390 meetuper.firstname = update.message.text391 meetuper.save()392 context.bot.send_message(393 chat_id=update.message.chat_id,394 text=f'ÐведиÑе ваÑÑ ÑамилиÑ',395 )396 context.bot.delete_message(397 chat_id=update.message.chat_id,398 message_id=update.message.message_id - 1399 )400 context.bot.delete_message(401 chat_id=update.message.chat_id,402 message_id=update.message.message_id403 )404 return 'LASTNAME'405def lastname_handler(context, update):406 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)407 meetuper.lastname = update.message.text408 meetuper.save()409 context.bot.send_message(410 chat_id=update.message.chat_id,411 text=f'УкажиÑе меÑÑо ÑабоÑÑ',412 )413 context.bot.delete_message(414 chat_id=update.message.chat_id,415 message_id=update.message.message_id - 1416 )417 context.bot.delete_message(418 chat_id=update.message.chat_id,419 message_id=update.message.message_id420 )421 return 'ORGANIZATION'422def organization_handler(context, update):423 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)424 meetuper.organization = update.message.text425 meetuper.save()426 context.bot.send_message(427 chat_id=update.message.chat_id,428 text=f'УкажиÑе ваÑÑ Ð´Ð¾Ð»Ð¶Ð½Ð¾ÑÑÑ',429 )430 context.bot.delete_message(431 chat_id=update.message.chat_id,432 message_id=update.message.message_id - 1433 )434 context.bot.delete_message(435 chat_id=update.message.chat_id,436 message_id=update.message.message_id437 )438 return 'POSITION'439def position_handler(context, update):440 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)441 meetuper.position = update.message.text442 meetuper.save()443 context.bot.send_message(444 chat_id=update.message.chat_id,445 text=f'ÐведиÑе Ð²Ð°Ñ Ð½Ð¾Ð¼ÐµÑ ÑелеÑона',446 )447 context.bot.delete_message(448 chat_id=update.message.chat_id,449 message_id=update.message.message_id - 1450 )451 context.bot.delete_message(452 chat_id=update.message.chat_id,453 message_id=update.message.message_id454 )455 return 'PHONENUMBER'456def phonenumber_handler(context, update):457 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)458 meetuper.phone_number = update.message.text459 meetuper.save()460 context.bot.send_message(461 chat_id=update.message.chat_id,462 text=f'ÐведиÑе Ð²Ð°Ñ email',463 )464 context.bot.delete_message(465 chat_id=update.message.chat_id,466 message_id=update.message.message_id - 1467 )468 context.bot.delete_message(469 chat_id=update.message.chat_id,470 message_id=update.message.message_id471 )472 return 'EMAIL'473def email_handler(context, update):474 meetuper = Meetuper.objects.get(chat_id=update.message.chat_id)475 meetuper.email = update.message.text476 meetuper.is_open_for_communication = True477 meetuper.save()478 message_text = '''479 ÐдеÑÑ Ð²Ñ ÑможеÑе заполниÑÑ Ð°Ð½ÐºÐµÑÑ Ð¾ Ñебе и пообÑаÑÑÑÑ Ñ Ð´ÑÑгими ÑÑаÑÑниками миÑапа.480 '''481 context.bot.send_message(482 chat_id=update.message.chat_id,483 text=dedent(message_text),484 reply_markup=get_communication_menu(update.message.chat_id)485 )486 context.bot.delete_message(487 chat_id=update.message.chat_id,488 message_id=update.message.message_id - 1489 )490 context.bot.delete_message(491 chat_id=update.message.chat_id,492 message_id=update.message.message_id493 )494 return 'COMMUNICATION_MENU'495def meetup_description_menu_handler(context, update):496 query = update.callback_query497 if query.data == 'description':498 context.bot.send_message(499 chat_id=query.message.chat_id,500 text=f'ÐÑогÑамма миÑапа: \n',501 reply_markup=get_meetup_menu()502 )503 context.bot.delete_message(504 chat_id=query.message.chat_id,505 message_id=query.message.message_id506 )507 return 'STAGE'508 elif query.data == 'main_menu':509 context.bot.send_message(510 chat_id=query.message.chat_id,511 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',512 reply_markup=get_main_menu(query.message.chat_id)513 )514 context.bot.delete_message(515 chat_id=query.message.chat_id,516 message_id=query.message.message_id517 )518 return 'MAIN_MENU'519 elif query.data == 'question':520 context.bot.send_message(521 chat_id=query.message.chat_id,522 text=f'ÐÑбеÑиÑе ÑÑейдж Ñ Ð¸Ð½ÑеÑеÑÑÑÑим ÐÐ°Ñ ÑпикеÑом',523 reply_markup=get_meetup_menu()524 )525 context.bot.delete_message(526 chat_id=query.message.chat_id,527 message_id=query.message.message_id528 )529 return 'SPEAKERS_BLOCK'530def stage_handler(context, update):531 query = update.callback_query532 if query.data.isdigit():533 user = f"user_tg_{query.message.chat_id}"534 _database.set(535 user,536 json.dumps({'stage': query.data})537 )538 message_text = f'''539 CпиÑок докладов поÑока "{Stage.objects.get(id=query.data).title}"540 '''541 context.bot.send_message(542 chat_id=query.message.chat_id,543 text=dedent(message_text),544 reply_markup=get_stage_menu(query.data)545 )546 context.bot.delete_message(547 chat_id=query.message.chat_id,548 message_id=query.message.message_id549 )550 return 'BLOCK'551 elif query.data == 'back':552 context.bot.send_message(553 chat_id=query.message.chat_id,554 text=f'ÐÑогÑамма миÑапа: \n',555 reply_markup=get_meetup_menu()556 )557 context.bot.delete_message(558 chat_id=query.message.chat_id,559 message_id=query.message.message_id560 )561 return 'STAGE'562 elif query.data == 'main_menu':563 context.bot.send_message(564 chat_id=query.message.chat_id,565 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',566 reply_markup=get_main_menu(query.message.chat_id)567 )568 context.bot.delete_message(569 chat_id=query.message.chat_id,570 message_id=query.message.message_id571 )572 return 'MAIN_MENU'573def block_handler(context, update):574 query = update.callback_query575 if query.data.isdigit():576 block = Block.objects.get(id=query.data)577 message_text = f'''578 <b><i>{block.start_time} - {block.end_time}579 Ðлок "{block.title}"</i></b>580 '''581 for event in block.events.all():582 message_text += f'''583 <b>{event.title}</b> 584 {event.start_time} - {event.end_time}585 '''586 if event.speaker:587 message_text += f'{event.speaker.participant.firstname} {event.speaker.participant.lastname}\n'588 context.bot.send_message(589 chat_id=query.message.chat_id,590 text=dedent(message_text),591 parse_mode='HTML',592 reply_markup=get_back_menu()593 )594 context.bot.delete_message(595 chat_id=query.message.chat_id,596 message_id=query.message.message_id597 )598 return 'BLOCK'599 elif query.data == 'back':600 context.bot.send_message(601 chat_id=query.message.chat_id,602 text=f'ÐÑогÑамма миÑапа: \n',603 reply_markup=get_meetup_menu()604 )605 context.bot.delete_message(606 chat_id=query.message.chat_id,607 message_id=query.message.message_id608 )609 return 'STAGE'610 611 else:612 user = f'user_tg_{query.message.chat_id}'613 stage_id = json.loads(_database.get(user))['stage']614 message_text = f'''615 616 CпиÑок докладов поÑока "{Stage.objects.get(id=stage_id).title}" 617 618 '''619 context.bot.send_message(620 chat_id=query.message.chat_id,621 text=dedent(message_text),622 reply_markup=get_stage_menu(stage_id)623 )624 context.bot.delete_message(625 chat_id=query.message.chat_id,626 message_id=query.message.message_id627 )628 return 'STAGE'629def speakers_block_handler(context, update):630 query = update.callback_query631 chat_id = query.message.chat_id632 if query.data.isdigit():633 user = f"user_tg_{chat_id}"634 _database.set(635 user,636 json.dumps({'stage': query.data})637 )638 message_text = f'''639 CпиÑок докладов поÑока "{Stage.objects.get(id=query.data).title}"640 '''641 context.bot.send_message(642 chat_id=chat_id,643 text=dedent(message_text),644 reply_markup=get_stage_menu(query.data)645 )646 context.bot.delete_message(647 chat_id=chat_id,648 message_id=query.message.message_id649 )650 return 'SPEAKERS'651 elif query.data == 'main_menu':652 context.bot.send_message(653 chat_id=chat_id,654 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',655 reply_markup=get_main_menu(chat_id)656 )657 context.bot.delete_message(658 chat_id=chat_id,659 message_id=query.message.message_id660 )661 return 'MAIN_MENU'662def speakers_handler(context, update):663 query = update.callback_query664 chat_id = query.message.chat_id665 if query.data.isdigit():666 user = f"user_tg_{chat_id}"667 _database.set(668 user,669 json.dumps({'block': query.data})670 )671 context.bot.send_message(672 chat_id=chat_id,673 text=f'СпикеÑÑ Ð² блоке {Block.objects.get(id=query.data).title}',674 reply_markup=get_block_speakers(query.data)675 )676 context.bot.delete_message(677 chat_id=chat_id,678 message_id=query.message.message_id679 )680 return 'QUESTION'681 elif query.data == 'back':682 context.bot.send_message(683 chat_id=chat_id,684 text=f'ÐÑогÑамма миÑапа: \n',685 reply_markup=get_meetup_menu()686 )687 context.bot.delete_message(688 chat_id=chat_id,689 message_id=query.message.message_id690 )691 return 'SPEAKERS_BLOCK'692def question_handler(context, update):693 query = update.callback_query694 chat_id = query.message.chat_id695 user = f'user_tg_{chat_id}'696 block_id = json.loads(_database.get(user))['block']697 if query.data == 'back':698 context.bot.send_message(699 chat_id=chat_id,700 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',701 reply_markup=get_stage_menu(block_id)702 )703 context.bot.delete_message(704 chat_id=chat_id,705 message_id=query.message.message_id706 )707 return 'SPEAKERS'708 _database.set(709 user,710 json.dumps({711 'speaker': query.data,712 'block': block_id713 })714 )715 context.bot.send_message(716 chat_id=chat_id,717 text='ÐведиÑе ÐÐ°Ñ Ð²Ð¾Ð¿ÑоÑ',718 )719 context.bot.delete_message(720 chat_id=chat_id,721 message_id=query.message.message_id722 )723 return 'SAVE_QUESTION'724def save_question_handler(context, update):725 query = update.callback_query726 chat_id = update.message.chat_id727 user = f'user_tg_{chat_id}'728 speaker_id = json.loads(_database.get(user))['speaker']729 speaker = Meetuper.objects.get(chat_id=speaker_id).speaker730 meetuper = Meetuper.objects.get(chat_id=chat_id)731 question_text = update.message.text732 send_notify_to_speaker(context, speaker_id)733 question = Question(734 text=question_text,735 speaker=speaker,736 meetuper=meetuper737 )738 question.save()739 context.bot.send_message(740 chat_id=chat_id,741 text=f'ÐÐ°Ñ Ð²Ð¾Ð¿ÑÐ¾Ñ Ð¾ÑпÑавлен!',742 parse_mode='HTML',743 reply_markup=get_main_menu(chat_id)744 )745 context.bot.delete_message(746 chat_id=chat_id,747 message_id=update.message.message_id - 1748 )749 context.bot.delete_message(750 chat_id=chat_id,751 message_id=update.message.message_id752 )753 return 'MAIN_MENU'754def send_notify_to_speaker(context, speaker_id):755 speaker = Meetuper.objects.get(chat_id=speaker_id).speaker756 questions_query = speaker.received_questions.all()757 if not questions_query:758 context.bot.send_message(759 chat_id=speaker_id,760 text=f'Ðам задали вопÑоÑ.',761 )762 return763def questions_handler(context, update):764 query = update.callback_query765 chat_id = query.message.chat_id766 if query.data.isdigit():767 speaker_id = query.data768 context.bot.send_message(769 chat_id=chat_id,770 text=f'{speaker_id}',771 )772 return 'ASK_QUESTION'773 elif query.data == 'back':774 context.bot.send_message(775 chat_id=chat_id,776 text=f'ÐожеÑе ознакомиÑÑÑÑ Ñ Ð¿ÑогÑаммой миÑапа '777 f'<b><i>"{MeetupProgram.objects.get(current=True).title}"</i></b>.'778 f' или задаÑÑ Ð²Ð¾Ð¿ÑÐ¾Ñ Ð»ÑÐ±Ð¾Ð¼Ñ ÑпикеÑÑ',779 parse_mode='HTML',780 reply_markup=get_meetup_description_menu()781 )782 return 'MEETUP_DESCRIPTION_MENU'783def get_questions(tg_id):784 speaker = Meetuper.objects.get(chat_id=tg_id).speaker785 questions_query = speaker.received_questions.all()786 questions_print = ''787 for question in questions_query:788 questions_print += f'''789ÐопÑÐ¾Ñ Ð¾Ñ {question.meetuper.firstname} {question.meetuper.lastname}:790{question.text}791'''792 return questions_print793def question_list_handler(context, update):794 query = update.callback_query795 chat_id = query.message.chat_id796 if query.data == 'back':797 context.bot.send_message(798 chat_id=chat_id,799 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',800 reply_markup=get_main_menu(chat_id)801 )802 context.bot.delete_message(803 chat_id=chat_id,804 message_id=query.message.message_id805 )806 return 'MAIN_MENU'807def start_without_shipping(context, update):808 query = update.callback_query809 if query.data.isdigit():810 context.bot.delete_message(811 chat_id=query.message.chat_id,812 message_id=query.message.message_id813 )814 chat_id = query.message.chat.id815 payment_token = env.str('PAY_TOKEN')816 title = f'Donate â{chat_id}'817 description = 'Своим донаÑом Ð²Ñ Ð¿Ð¾Ð¼Ð¾Ð³Ð°ÐµÑе оÑганизоваÑÑ Ð¼Ð¸Ñап'818 payload = 'Custom_order'819 currency = 'RUB'820 prices = [821 LabeledPrice('Test', int(query.data) * 100),822 ]823 context.bot.sendInvoice(824 chat_id,825 title,826 description,827 payload,828 payment_token,829 currency,830 prices,831 )832 return 'MAIN_MENU'833 else:834 context.bot.send_message(835 chat_id=query.message.chat_id,836 text=f'Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',837 reply_markup=get_main_menu(query.message.chat_id)838 )839 context.bot.delete_message(840 chat_id=query.message.chat_id,841 message_id=query.message.message_id842 )843 return 'MAIN_MENU'844def precheckout_callback(update, context):845 query = update.pre_checkout_query846 if query.invoice_payload != f"Custom_order":847 context.bot.answer_pre_checkout_query(848 pre_checkout_query_id=query.id,849 ok=False,850 error_message="ЧÑо Ñо поÑло не Ñак"851 )852 else:853 context.bot.answer_pre_checkout_query(854 pre_checkout_query_id=query.id,855 ok=True856 )857def successful_payment_callback(update, context):858 meetuper = Meetuper.objects.get(chat_id=update.message.chat.id)859 Donation.objects.create(860 meetuper=meetuper,861 date=update.message.date,862 amount=update.message.successful_payment.total_amount / 100,863 )864 context.bot.send_message(865 chat_id=update.message.chat_id,866 text='Ð Ð°Ð´Ñ Ð²Ð¸Ð´ÐµÑÑ ÐÐ°Ñ Ð½Ð° миÑапе',867 reply_markup=get_main_menu(update.message.chat_id)868 )869 context.bot.delete_message(870 chat_id=update.message.chat_id,871 message_id=update.message.message_id - 1872 )873 return 'MAIN_MENU'874def set_meetuper_is_active(chat_id):875 meetuper, _ = Meetuper.objects.get_or_create(chat_id=chat_id)876 meetuper.is_active = True877 meetuper.save()878def handle_users_reply(update, context):879 db = get_database_connection()880 if update.message:881 user_reply = update.message.text882 chat_id = update.message.chat_id883 set_meetuper_is_active(chat_id)...
setup.py
Source:setup.py
...52async def on_message(message):53 if message.content.startswith('/sugestão'):54 try:55 canal = client.get_channel('467704726411018260')56 await client.delete_message(message)57 remover_sugestao = message.content.replace("/sugestão", "")58 separar = remover_sugestao.split("|", 1)59 embed = discord.Embed(60 title="SUGESTÃO ð¡",61 color=COR,62 description="Sugestão recebida. \nEnviada por: {}".format(message.author.mention)63 )64 embed.add_field(65 name="Sugestão:",66 value="```%s```" % "".join(separar[0]),67 inline=False68 )69 embed.add_field(70 name="Por quê?",71 value="```%s```" % "".join(separar[1]),72 inline=False73 )74 embed.set_footer(75 text="Sugestão postada com sucesso.",76 icon_url=message.author.avatar_url77 )78 await client.send_message(message.author, "Sua sugestão foi enviada!")79 time.sleep(3)80 botmsg = await client.send_message(canal, embed=embed)81 await client.add_reaction(botmsg, "ð")82 await client.add_reaction(botmsg, "ð")83 except IndexError:84 await client.send_message(message.author, "Uso correto do comando: /sugestão <sugestão> | <por quê adicionariamos?>")85 except:86 await client.send_message(message.author,"Desculpe pelo erro.")87 finally:88 pass89 90 if message.content.startswith('/dado'):91 numr = random.randint(1,6)92 embed = discord.Embed(93 title='Dado',94 color=COR,95 description=':game_die: Joguei o dado, o resultado é: {}'.format(str(numr))96 )97 await client.send_message(message.channel, embed=embed)98 if message.content.startswith('/moeda'):99 escolha = random.randint(1,2)100 if escolha == 1:101 await client.add_reaction(message, 'ð')102 if escolha == 2:103 await client.add_reaction(message, 'ð')104 if message.content.startswith('/comandos'):105 try:106 embed = discord.Embed(107 title='Comandos do bot:',108 color=COR,109 description='/userinfo `[usuário]` » Veja as informações de um usuário.\n'110 '/serverinfo » Veja as informações do servidor.\n'111 '/dado » Role um dado de um número de 1 á 6.\n'112 '/avatar `[usuário]` » Veja o avatar seu ou de um membro.\n'113 '/convite » Gere um convite para convidar todos para nossa comunidade.\n'114 '/ping » Veja o tempo de resposta do bot.\n'115 '/ajuda » Veja as informações básicas do servidor Barberians\n'116 '/moeda » Brinque de cara ou coroa.\n\n'117 '**UTILITÃRIOS:**\n'118 '/revisão `[nickname] | [motivo] | [por quê está irregular?]` » Crie uma revisão de seu banimento.\n'119 '/reportar `[usuário/nickname] | [motivo] | [prova]` » Denúncie um usuário do discord ou do servidor.\n'120 '/sugestão `[sugestão] | [por quê adicionariamos?]` » Crie uma sugestão.'121 )122 embed.set_author(name=message.server.name, icon_url='https://i.imgur.com/HzA0wHY.png')123 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')124 msg = await client.send_message(message.channel, '{}, enviamos uma mensagem em seu privado!'.format(message.author.mention))125 await client.send_message(message.author, embed=embed)126 except IndexError:127 time.sleep(2)128 await client.delete_message(msg)129 asyncio.sleep(21000)130 msg1 = await client.send_message(message.channel, 'Error')131 await client.delete_message(message)132 time.sleep(10)133 await client.delete_message(msg1)134 except:135 time.sleep(2)136 await client.delete_message(msg)137 asyncio.sleep(21000)138 tst = await client.send_message(message.channel, '{}, libere o privado!'.format(message.author.mention))139 await client.delete_message(message)140 time.sleep(10)141 await client.delete_message(tst)142 finally:143 pass144 if message.content.startswith('/avatar'):145 try:146 user = message.mentions[0]147 embed = discord.Embed(148 title="",149 color=COR,150 description='Clique [aqui](' + user.avatar_url + ') para acessar o avatar do {}.'.format(user.name)151 )152 embed.set_author(153 name=message.server.name,154 icon_url='https://i.imgur.com/yJey64O.png'155 )156 embed.set_image(157 url=user.avatar_url158 )159 await client.send_message(message.channel, embed=embed)160 except IndexError:161 await client.delete_message(message)162 msg = await client.send_message(message.channel, '{}, mencione um usuário existente, por exemplo, `/avatar @JohnnCosta`.'.format(message.author.mention))163 time.sleep(10)164 await client.delete_message(msg)165 except:166 msg1 = await client.send_message(message.channel, 'Desculpe pelo erro.')167 time.sleep(5)168 await client.delete_message(msg1)169 finally:170 pass171 if message.content.startswith('/say'):172 if '468087006736416779' in [role.id for role in message.author.roles]:173 args = message.content.split(" ")174 await client.send_message(message.channel, (" ".join(args[1:])))175 asyncio.sleep(1)176 await client.delete_message(message)177 asyncio.sleep(1)178 else:179 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')180 await client.delete_message(message)181 time.sleep(10)182 await client.delete_message(msglg)183 184 if message.content.startswith('/revisão'):185 try:186 canal = client.get_channel('466666024788295690')187 await client.delete_message(message)188 remover_revisão = message.content.replace("/revisão ", "")189 separar = remover_revisão.split("|", 2)190 embed = discord.Embed(191 title='REVISÃO â',192 color=COR,193 description='Revisão recebida. \nEnviada por: {}'.format(message.author.mention)194 )195 embed.add_field(196 name='**Nickname:**',197 value='```%s```' % ''.join(separar[0]),198 inline=False199 )200 embed.add_field(201 name='**Motivo:**',202 value='```%s```' % ''.join(separar[1]),203 inline=False204 )205 embed.add_field(206 name='**Por quê está irregular?**',207 value='```%s```' % ''.join(separar[2]),208 inline=False209 )210 embed.set_footer(text='Revisão postada com sucesso.', icon_url=message.author.avatar_url211 )212 await client.send_message(message.author, 'Sua revisão foi enviada')213 time.sleep(3)214 await client.send_message(canal, embed=embed)215 except IndexError:216 await client.send_message(message.author, '{}, use /revisão <nickname> | <motivo> | <Por quê está irregular?>'.format(message.author.mention))217 except:218 await client.send_message(message.author, 'Desculpe pelo erro.')219 print('Error')220 finally:221 pass222 if message.content.startswith('/reportar'):223 try:224 canal = client.get_channel('466665871218049024')225 remover_reportar = message.content.replace("/reportar ", "")226 separar = remover_reportar.split("|", 2)227 embed = discord.Embed(228 title="DENÃNCIA ð",229 color=COR,230 description="Denúncia recebida. \nEnviada por: {}".format(message.author.mention)231 )232 embed.add_field(233 name="Suspeito:",234 value="%s" % "".join(separar[0]),235 inline=False236 )237 embed.add_field(238 name="Motivo:",239 value="%s" % "".join(separar[1]),240 inline=False241 )242 embed.add_field(243 name="Prova:",244 value="%s" % "".join(separar[2]),245 inline=False246 )247 embed.set_footer(248 text="Denúncia postada com sucesso.",249 icon_url=message.author.avatar_url250 )251 await client.send_message(canal, embed=embed)252 await client.delete_message(message)253 except IndexError:254 await client.send_message(message.author, '{}, use /reportar <Suspeito> | <Motivo> | <Prova>'.format(message.author.mention))255 await client.delete_message(message)256 except:257 await client.send_message(message.author, 'Desculpe pelo erro.')258 await client.delete_message(message)259 finally:260 pass261 if message.content.startswith('!/ajuda'):262 try:263 embed = discord.Embed(264 title='Você solicitou o comando e aqui estamos enviando umas informações básicas sobre o End.',265 color=COR,266 description='**Seja bem-vindo ao discord da rede Barberians. Segue abaixo informações básicas sobre a rede que podem te ajudar!**\n\nIP: jogar.end-mc.com\n\nLoja: [clique aqui!](http://loja.end-mc.com)\n\nTwitter: [clique aqui!](https://twitter.com/ServidorEnd)\n\nFórum: **Em breve**\n\n***__Caso precise de outro tipo de ajuda contate um membro da equipe__***'267 )268 embed.set_author(name=message.server.name, icon_url='https://i.imgur.com/HzA0wHY.png')269 embed.set_thumbnail(url='https://i.imgur.com/HzA0wHY.png')270 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')271 msg = await client.send_message(message.channel, '{}, enviamos uma mensagem em seu privado!'.format(message.author.mention))272 await client.send_message(message.author, embed=embed)273 except IndexError:274 time.sleep(2)275 await client.delete_message(msg)276 asyncio.sleep(21000)277 msg1 = await client.send_message(message.channel, 'Error')278 await client.delete_message(message)279 time.sleep(10)280 await client.delete_message(msg1)281 except:282 time.sleep(2)283 await client.delete_message(msg)284 asyncio.sleep(21000)285 tst = await client.send_message(message.channel, '{}, libere o privado!'.format(message.author.mention))286 await client.delete_message(message)287 time.sleep(10)288 await client.delete_message(tst)289 finally:290 pass291 292 293 if message.content.startswith('/anunciar'):294 if '468087006736416779' in [role.id for role in message.author.roles]:295 await client.delete_message(message)296 args = message.content.split(" ")297 embed = discord.Embed(298 title="End ð¢",299 color=COR,300 description=" ".join(args[1:])301 )302 embed.set_footer(303 text="Enviado por: {} ⢠Barberians".format(message.author.name),304 icon_url='https://i.imgur.com/HzA0wHY.png'305 )306 embed.set_thumbnail(307 url='https://i.imgur.com/HzA0wHY.png'308 )309 await client.send_message(message.channel, "@everyone")310 await client.send_message(message.channel, embed=embed)311 else:312 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')313 await client.delete_message(message)314 time.sleep(10)315 await client.delete_message(msglg)316 if message.content.startswith('/serverinfo'):317 embed = discord.Embed(318 title='Informações do Servidor',319 color=0x03c3f5,320 descripition='Essas são as informações\n')321 embed.set_author(name=message.server.name, icon_url='https://i.imgur.com/HzA0wHY.png')322 embed.add_field(name="Nome:", value=message.server.name, inline=True)323 embed.add_field(name=":crown: Dono:", value=message.server.owner.mention)324 embed.add_field(name="ID:", value=message.server.id, inline=True)325 embed.add_field(name="Cargos:", value=len(message.server.roles), inline=True)326 embed.add_field(name=":family: Membros:", value=len(message.server.members), inline=True)327 embed.add_field(name=":date: Criado em:", value=message.server.created_at.strftime("%d %b %Y %H:%M"))328 embed.add_field(name="Emojis:", value=f"{len(message.server.emojis)}/100")329 embed.add_field(name=":flag_br: Região:", value=str(message.server.region).title())330 embed.set_thumbnail(url='https://i.imgur.com/HzA0wHY.png')331 embed.set_footer(text="Barberians", icon_url="https://i.imgur.com/HzA0wHY.png")332 await client.send_message(message.channel, embed=embed) 333 if message.content.lower().startswith('/userinfo'):334 try:335 tmp1 = datetime.datetime.now()336 utcnow = datetime.time(hour=tmp1.hour, minute=tmp1.minute, second=tmp1.second)337 del tmp1338 user = message.mentions[0]339 userjoinedat = str(user.joined_at).split('.', 1)[0]340 usercreatedat = str(user.created_at).split('.', 1)[0]341 userembed = discord.Embed(342 title="Informações do usuário",343 description="\n",344 color=COR345 )346 userembed.set_author(347 name=user.server.name,348 icon_url=user.server.icon_url349 )350 userembed.add_field(351 name="Nome de usuário:",352 value=user.name353 )354 userembed.add_field(355 name="Juntou-se ao servidor em:",356 value=userjoinedat357 )358 userembed.add_field(359 name="Usuário criado em:",360 value=usercreatedat361 )362 userembed.add_field(363 name="Identificação:",364 value=user.discriminator365 )366 userembed.add_field(367 name="ID de Usuário:",368 value=user.id369 )370 userembed.set_thumbnail(371 url='https://i.imgur.com/HzA0wHY.png'372 )373 userembed.set_footer(374 text="Barberians",375 icon_url="https://i.imgur.com/HzA0wHY.png"376 )377 await client.send_message(message.channel, embed=userembed)378 except IndexError:379 await client.delete_message(message)380 msg = await client.send_message(message.channel, "{}, mencione um usuário existente, por exemplo, `/userinfo @JohnnCosta`.".format(message.author.mention))381 time.sleep(10)382 await client.delete_message(msg)383 except:384 await client.delete_message(message)385 msg1 = await client.send_message(message.channel, "Desculpe pelo erro.")386 time.sleep(5)387 await client.delete_message(msg1)388 finally:389 pass390 if message.content.startswith('/kick'):391 if '468087006736416779' in [role.id for role in message.author.roles]:392 asyncio.sleep(10)393 await client.delete_message(message)394 channel = client.get_channel('448449971629588481')395 user = message.mentions[0] 396 await client.kick(user)397 embed = discord.Embed(398 title='EXPULSO â',399 color=COR,400 description='O usuário **{}#{}**, foi expulso com sucesso!\nAutor: {}'.format(user.name, user.discriminator, message.author.mention)401 )402 embed.set_thumbnail(403 url='https://i.imgur.com/HzA0wHY.png'404 )405 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')406 await client.send_message(channel, embed=embed)407 else:408 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')409 time.sleep(10)410 await client.delete_message(message)411 await client.delete_message(msglg)412 if message.content.startswith('/tempban'):413 try:414 if '468087006736416779' in [role.id for role in message.author.roles]:415 args = message.content.split(" ")416 tempo = (" ".join(args[3:]))417 await client.delete_message(message)418 channel1 = client.get_channel('448449971629588481')419 user = message.mentions[0]420 temp = args[2]421 timesquad = int(temp)422 reallytime = datetime.timedelta(seconds=timesquad)423 await client.ban(user)424 join = (" ".join(args[2:]))425 embed = discord.Embed(426 title='BANIDO â',427 color=COR,428 description='O usuário **{}#{}**, foi banido temporariamente!\n\n**Duração**: {}\n**Motivo**: {}\n**Autor**: {}'.format(user.name, user.discriminator, reallytime, tempo, message.author.mention)429 )430 embed.set_thumbnail(431 url='https://i.imgur.com/HzA0wHY.png'432 )433 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')434 await client.send_message(canal, embed=embed)435 time.sleep(timesquad)436 await client.unban(message.server, user)437 else:438 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')439 time.sleep(10)440 await client.delete_message(message)441 await client.delete_message(msglg)442 except IndexError:443 msg = await client.send_message(message.channel, 'O usuário não é existente ou saiu!')444 time.sleep(10)445 await client.delete_message(msg)446 except:447 msg1 = await client.send_message(message.channel, 'Teste')448 time.sleep(10)449 await client.delete_message(msg1)450 finally:451 pass452 if message.content.startswith('/ban'):453 try:454 if '468087006736416779' in [role.id for role in message.author.roles]:455 asyncio.sleep(10)456 args = message.content.split(" ")457 await client.delete_message(message)458 channel1 = client.get_channel('448449971629588481')459 user = message.mentions[0]460 await client.ban(user)461 join = (" ".join(args[2:]))462 embed = discord.Embed(463 title='BANIDO â',464 color=COR,465 description='O usuário **{}#{}**, foi banido!\n\n**Motivo**: {}\n**Autor**: {}'.format(user.name, user.discriminator, join, message.author.mention)466 )467 embed.set_thumbnail(468 url='https://i.imgur.com/HzA0wHY.png'469 )470 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')471 await client.send_message(channel1, embed=embed)472 else:473 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')474 time.sleep(10)475 await client.delete_message(message)476 await client.delete_message(msglg) 477 except IndexError:478 msg = await client.send_message(message.channel, '{}, use /ban [usuário] [motivo]'.format(message.author.mention))479 time.sleep(10)480 await client.delete_message(msg)481 except:482 a = await client.send_message(message.channel, '{}, use /ban [usuário] [motivo].'.format(message.author.mention))483 time.sleep(5)484 await client.delete_message(a)485 finally:486 pass487 if message.content.startswith('/mute'):488 if '468087006736416779' in [role.id for role in message.author.roles]:489 args = message.content.split(" ")490 join = (" ".join(args[2:]))491 user = message.mentions[0]492 canal = client.get_channel('448449971629588481')493 cargo = discord.utils.get(user.server.roles, name="Silenciado")494 embed = discord.Embed(495 title='SILENCIADO ð',496 color=COR,497 description='O usuário **{}#{}**, foi silenciado!\n\n**Motivo**: {}\n**Autor**: {}'.format(user.name, user.discriminator, join, message.author.mention))498 embed.set_thumbnail(url='https://i.imgur.com/HzA0wHY.png')499 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')500 await client.send_message(canal, embed=embed)501 await client.add_roles(user, cargo)502 else:503 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')504 time.sleep(10)505 await client.delete_message(message)506 await client.delete_message(msglg)507 if message.content.startswith('/unmute'):508 if '468087006736416779' in [role.id for role in message.author.roles]:509 args = message.content.split(" ")510 user = message.mentions[0]511 cargo = discord.utils.get(user.server.roles, name='Silenciado')512 canal = client.get_channel('448449971629588481')513 embed = discord.Embed(514 title='DESMUTADO ð',515 color=COR,516 description='O usuário **{}#{}**, não está mais silenciado!\n\nAutor: {}'.format(user.name, user.discriminator, message.author.mention)517 )518 embed.set_thumbnail(519 url='https://i.imgur.com/HzA0wHY.png'520 )521 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')522 await client.send_message(canal, embed=embed)523 await client.remove_roles(user, cargo)524 else:525 msg = await client.send_message(message.channel, 'â Você não pode fazer isso!')526 time.sleep(10)527 await client.delete_message(message)528 await client.delete_message(msg)529 if message.content.startswith('/tempmute'):530 try:531 if '468087214241218560' or '468087006736416779' in [role.id for role in message.author.roles]:532 args = message.content.split(" ")533 tempo = (" ".join(args[3:]))534 user = message.mentions[0]535 cargo = discord.utils.get(user.server.roles, name='Silenciado')536 canal = client.get_channel('448449971629588481')537 await client.add_roles(user, cargo)538 temp = args[2]539 timesquad = int(temp)540 reallytime = datetime.timedelta(seconds=timesquad)541 embed = discord.Embed(542 title='SILENCIADO ð',543 color=COR,544 description='O usuário **{}#{}**, foi silenciado!\n\n**Duração**: {}\n**Motivo**: {}\n**Autor**: {}'.format(user.name, user.discriminator, reallytime, tempo, message.author.mention)545 )546 embed.set_thumbnail(547 url='https://i.imgur.com/HzA0wHY.png'548 )549 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')550 await client.send_message(canal, embed=embed)551 time.sleep(timesquad)552 cargo = discord.utils.get(user.server.roles, name='Silenciado')553 await client.remove_roles(user, cargo)554 else:555 msglg = await client.send_message(message.channel, 'â Você não pode fazer isso!')556 time.sleep(10)557 await client.delete_message(message)558 await client.delete_message(msglg)559 except IndexError:560 msg = await client.send_message(message.channel, 'O usuário não é existente ou saiu!')561 time.sleep(10)562 await client.delete_message(msg)563 except:564 msg1 = await client.send_message(message.channel, 'Teste')565 time.sleep(10)566 await client.delete_message(msg1)567 finally:568 pass569 if message.content.startswith('/helpstaff'):570 try:571 if '468087214241218560' or '468087006736416779' in [role.id for role in message.author.roles]:572 embed = discord.Embed(573 title='PUNIÃÃES & TEMPOS:',574 color=COR,575 description='**Uso de caps-lock excessivo** - *__14400__ segundos de tempmute*\n\n'576 '**Spam** - *__14400__ segundos de tempmute*\n\n'577 '**Flood** - *__14400__ segundos de mute*\n\n'578 '**Divulgação/Citação de servidores** - *Ban permanente*\n\n'579 '**Iniciativa de flood** - *__21600__ segundos de mute*\n\n'580 '**Mensagem fake** - *__10800__ segundos de mute*\n\n'581 '**Ameaça ao jogador** - *Ban temporário de __86400__ segundos*\n\n'582 '**Ameaça ao servidor** - *Ban permanente*.\n\n' 583 '**Abuso de bug´s** - *Ban permanente*.\n\n'584 '**Uso inadequado do chat** - *__43200__ segundos de mute*\n\n'585 '**Discriminação** - *Ban temporário de __172800__ segundos*.\n\n'586 '**Anti-Jogo** - *Ban temporário de __43200__ segundos*.\n\n'587 '**Falsificação de provas** - *Ban permanente*.\n\n' 588 '**Chantagem** - *Ban permanente*.\n\n'589 '**Ofensa à staff** - *Ban permanente*.\n\n' 590 '**Uso de hack** - *Ban permanente*.\n\n'591 '**Uso de algum programa proibido** - *Ban permanente*.\n\n'592 '**Palavras inadequadas** - *__28800__ segundos de mute*.\n\n'593 )594 embed.set_author(name=message.server.name, icon_url='https://i.imgur.com/HzA0wHY.png')595 embed.set_footer(text='Barberians', icon_url='https://i.imgur.com/HzA0wHY.png')596 msg = await client.send_message(message.channel, '{}, enviamos uma mensagem em seu privado!'.format(message.author.mention))597 await client.send_message(message.author, embed=embed)598 else:599 mssg = await client.send_message(message.channel, 'â Você não pode fazer isso!')600 time.sleep(10)601 await client.delete_message(message)602 await client.delete_message(mssg)603 except IndexError:604 time.sleep(2)605 await client.delete_message(msg)606 asyncio.sleep(21000)607 msg1 = await client.send_message(message.channel, 'Comando incorreto!')608 await client.delete_message(message)609 time.sleep(10)610 await client.delete_message(msg1)611 except:612 time.sleep(2)613 await client.delete_message(msg)614 asyncio.sleep(21000)615 tst = await client.send_message(message.channel, '{}, libere o privado!'.format(message.author.mention))616 await client.delete_message(message)617 time.sleep(10)618 await client.delete_message(tst)619 finally:620 pass621 if message.content.startswith('/staff-'):622 try:623 if '468087214241218560' in [role.id for role in message.author.roles]:624 embed = discord.Embed(625 title='Comandos para o cargo `STAFF`:',626 color=COR,627 description='/tempmute [usuário] » Silenciar temporariamente do discord.\n'628 'exemplo: `/tempmute @JohnnCosta 28800 Palavras inadequadas`\n\n'629 '*Lembrando que os tempmute é contato por segundo! Caso esteja com dúvidas em relação ao tempo de cada punição, envie em `#comandos-dos-bots` ´/helpstaff´.*'630 )631 embed.set_author(name=message.server.name, icon_url='https://i.imgur.com/yJey64O.png')632 embed.set_footer(text='End', icon_url='https://i.imgur.com/yJey64O.png')633 msg = await client.send_message(message.channel, '{}, enviamos uma mensagem em seu privado!'.format(message.author.mention))634 await client.send_message(message.author, embed=embed)635 else:636 mssg = await client.send_message(message.channel, 'â Você não pode fazer isso!')637 time.sleep(10)638 await client.delete_message(message)639 await client.delete_message(mssg)640 except IndexError:641 time.sleep(2)642 await client.delete_message(msg)643 asyncio.sleep(21000)644 msg1 = await client.send_message(message.channel, 'Comando incorreto!')645 await client.delete_message(message)646 time.sleep(10)647 await client.delete_message(msg1)648 except:649 time.sleep(2)650 await client.delete_message(msg)651 asyncio.sleep(21000)652 tst = await client.send_message(message.channel, '{}, libere o privado!'.format(message.author.mention))653 await client.delete_message(message)654 time.sleep(10)655 await client.delete_message(tst)656 finally:657 pass 658 if message.content.startswith('/staff+'):659 try:660 if '468087006736416779' in [role.id for role in message.author.roles]:661 embed = discord.Embed(662 title='Comandos para o cargo `STAFF+`:',663 color=COR,664 description='/ban [usuário] [motivo] » Banimento permanentemente do discord.\n'665 'exemplo: `/ban @JohnnCosta Divulgação de link´s`\n\n'666 '/kick [usuário] » Expulsão do discord.\n'667 'exemplo: `/kick @JohnnCosta`\n\n'668 '/mute [usuário] [motivo] » Mute permanentemente do discord.\n'669 'exemplo: `/mute @JohnnCosta Spam`\n\n'670 '/unmute [usuário] » Unmute do discord.\n'671 'exemplo: `/unmute @JohnnCosta`\n\n'672 '/tempban [usuário] [duração] [motivo] » Banimento temporariamente do discord.\n'673 'exemplo: `/tempban @JohnnCosta 172800 Discriminação`\n\n'674 '/tempmute [usuário] [duração] [motivo] » Mute temporariamente do discord.\n'675 'exemplo: `/tempmute @JohnnCosta 21600 Iniciativa de Flood`\n\n'676 '/say [mensagem] » bot repete a mensagem.\n'677 'exemplo: `/say Olá`\n\n'678 '/anunciar [mensagem] » bot repete em Embed\n'679 'exemplo: `/anunciar Olá`\n\n'680 )681 embed.set_author(name=message.server.name, icon_url='https://i.imgur.com/yJey64O.png')682 embed.set_footer(text='End', icon_url='https://i.imgur.com/yJey64O.png')683 msg = await client.send_message(message.channel, '{}, enviamos uma mensagem em seu privado!'.format(message.author.mention))684 await client.send_message(message.author, embed=embed)685 else:686 mssg = await client.send_message(message.channel, 'â Você não pode fazer isso!')687 time.sleep(10)688 await client.delete_message(message)689 await client.delete_message(mssg)690 except IndexError:691 time.sleep(2)692 await client.delete_message(msg)693 await asyncio.sleep(21000)694 msg1 = await client.send_message(message.channel, 'Comando incorreto!')695 await client.delete_message(message)696 time.sleep(10)697 await client.delete_message(msg1)698 except:699 time.sleep(2)700 await client.delete_message(msg)701 await asyncio.sleep(21000)702 tst = await client.send_message(message.channel, '{}, libere o privado!'.format(message.author.mention))703 await client.delete_message(message)704 time.sleep(10)705 await client.delete_message(tst)706 finally:707 pass708 if message.content.lower().startswith('/ping'):709 embed1 = discord.Embed(710 title='Pong! ð¾',711 color=COR,712 description="Pong `calc ms`"713 )714 bot_msg = await client.send_message(message.channel, embed=embed1)715 time_delta = bot_msg.timestamp - message.timestamp716 embed = discord.Embed(717 title='Pong!',718 color=COR,719 description=':ping_pong: Ping: `{ping_sec}` ms.'.format(ping_sec=time_delta.total_seconds())720 )721 await client.edit_message(bot_msg, embed=embed)722 if message.content.startswith('/convite'):723 msg = await client.send_message(message.channel, 'Convite do servidor: https://discord.gg/aWftHCv')724 time.sleep(50)725 await client.delete_message(msg)...
kill.py
Source:kill.py
...24 if not p.bot: 25 if member.name == "Neko Public":26 msg = await self.client.say("{} kill all of the World with a Bomb of Hate.".format(p.mention))27 await asyncio.sleep(120)28 await self.client.delete_message(msg)29 if member is None:30 msg = await self.client.say("You need to choose a member, buddy!")31 await asyncio.sleep(120)32 await self.client.delete_message(msg)33 if member is p: 34 msg = await self.client.say("{} died".format(p.mention))35 await asyncio.sleep(120)36 await self.client.delete_message(msg)37 else: 38 choice = random.randint(1, 75)39 if choice == 1:40 msg1 = await self.client.say("{0} was killed by a wrecking Ball".format(member.name))41 await asyncio.sleep(120)42 await self.client.delete_message(msg1)43 if choice == 2:44 msg1 = await self.client.say("{0} was killed by trying to dive between underwater mines, unfortunately {0} touched one....".format(member.name, member.name))45 await asyncio.sleep(120)46 await self.client.delete_message(msg1)47 if choice == 3:48 msg1 = await self.client.say("{0} died because {1} stabbed him a toothbrush in his eye".format(member.name, p.name))49 await asyncio.sleep(120)50 await self.client.delete_message(msg1)51 if choice == 4:52 msg1 = await self.client.say("{0} killed {1}.".format(member.name, p.name))53 await asyncio.sleep(120)54 await self.client.delete_message(msg1)55 if choice == 5:56 msg1 = await self.client.say("{0} ate too much pizza and died.".format(member.name))57 await asyncio.sleep(120)58 await self.client.delete_message(msg1)59 if choice == 6:60 msg1 = await self.client.say("{0} got killed by Illuminati.".format(member.name))61 await asyncio.sleep(120)62 await self.client.delete_message(msg1)63 if choice == 7:64 msg1 = await self.client.say("{0} got killed by smoke to much weed".format(member.name))65 await asyncio.sleep(120)66 await self.client.delete_message(msg1)67 if choice == 8:68 msg1 = await self.client.say("{0} pressed delete. It deleted {1}.".format(p.name, member.name))69 await asyncio.sleep(120)70 await self.client.delete_message(msg1)71 if choice == 9:72 msg1 = await self.client.say("{0} played a game from EA. He payed his live to EA...".format(member.name))73 await asyncio.sleep(120)74 await self.client.delete_message(msg1)75 if choice == 10:76 msg1 = await self.client.say("{0} click return. It returns back to the darkness.".format(member.name))77 await asyncio.sleep(120)78 await self.client.delete_message(msg1)79 if choice == 11:80 msg1 = await self.client.say("{0} dies because he offended Neko".format(member.name))81 await asyncio.sleep(120)82 await self.client.delete_message(msg1)83 if choice == 12:84 msg1 = await self.client.say("{0} was murdered by {1} and everyone knows it, but there is no proof.".format(member.name, p.name))85 await asyncio.sleep(120)86 await self.client.delete_message(msg1)87 if choice == 13:88 msg1 = await self.client.say("{0} died from a creeper explosion".format(member.name))89 await asyncio.sleep(120)90 await self.client.delete_message(msg1)91 if choice == 14:92 msg1 = await self.client.say("{0} was squashed by a storm of sharks".format(member.name))93 await asyncio.sleep(120)94 await self.client.delete_message(msg1)95 if choice == 15:96 msg1 = await self.client.say("{0} decided it was a good idea to fight a tiger while smelling like meat. It did not end well.".format(member.name))97 await asyncio.sleep(120)98 await self.client.delete_message(msg1)99 if choice == 16:100 msg1 = await self.client.say("{0} is now a meme in the EU".format(member.name))101 await asyncio.sleep(120)102 await self.client.delete_message(msg1)103 if choice == 17:104 msg1 = await self.client.say("{0} tried to outrun a train, the train won.".format(member.name))105 await asyncio.sleep(120)106 await self.client.delete_message(msg1)107 if choice == 18:108 msg1 = await self.client.say("{0} tried to outrun a tank, the tank won.".format(member.name))109 await asyncio.sleep(120)110 await self.client.delete_message(msg1)111 if choice == 19:112 msg1 = await self.client.say("{0} tried to catch a rocket, the rocket is now red. ".format(member.name))113 await asyncio.sleep(120)114 await self.client.delete_message(msg1)115 if choice == 20:116 msg1 = await self.client.say("{0} tried to fight against a shark while smelling like blood. The shark is now full ".format(member.name))117 await asyncio.sleep(120)118 await self.client.delete_message(msg1)119 if choice == 21:120 msg1 = await self.client.say("{0} tried to fight against Neko. Neko banned him. ".format(member.name))121 await asyncio.sleep(120)122 await self.client.delete_message(msg1)123 if choice == 22:124 msg1 = await self.client.say("{0} is still alive. But {1} died trying to kill him ".format(member.name, p.name))125 await asyncio.sleep(120)126 await self.client.delete_message(msg1)127 if choice == 23:128 msg1 = await self.client.say("{0} tried to rob a bank. He blowed himselfe up ".format(member.name))129 await asyncio.sleep(120)130 await self.client.delete_message(msg1)131 if choice == 24:132 msg1 = await self.client.say("{0} failed at russian roulette but {1} died too ".format(member.name, p.name))133 await asyncio.sleep(120)134 await self.client.delete_message(msg1)135 if choice == 25:136 msg1 = await self.client.say("{0} watched so much hentais that his brain exploded.".format(member.name))137 await asyncio.sleep(120)138 await self.client.delete_message(msg1)139 if choice == 26:140 msg1 = await self.client.say("{0} jumped from a skyscraper. ".format(member.name))141 await asyncio.sleep(120)142 await self.client.delete_message(msg1)143 if choice == 27:144 msg1 = await self.client.say("{0} opened a window in the submarine while it was diving.".format(member.name))145 await asyncio.sleep(120)146 await self.client.delete_message(msg1)147 if choice == 28:148 msg1 = await self.client.say("{0} watched so much anime that he starved to dead.".format(member.name))149 await asyncio.sleep(120)150 await self.client.delete_message(msg1)151 if choice == 29:152 msg1 = await self.client.say("{0} tried to fight with a bear. Little Spoiler the bear won ".format(member.name))153 await asyncio.sleep(120)154 await self.client.delete_message(msg1)155 if choice == 30:156 msg1 = await self.client.say("{0} was too long in the sauna and dried up ".format(member.name))157 await asyncio.sleep(120)158 await self.client.delete_message(msg1)159 if choice == 31:160 msg1 = await self.client.say("{1} killed {0} with a fish. ".format(p.name, member.name))161 await asyncio.sleep(120)162 await self.client.delete_message(msg1)163 if choice == 32:164 msg1 = await self.client.say("{0} tried to catch a bullet with his head. It wasnt a good Idea... ".format(member.name))165 await asyncio.sleep(120)166 await self.client.delete_message(msg1)167 if choice == 33:168 msg1 = await self.client.say("{0} tried to brake the worldrekord in eating pizza. He bursted".format(member.name))169 await asyncio.sleep(120)170 await self.client.delete_message(msg1)171 if choice == 34:172 msg1 = await self.client.say("{1} hired me to kill {0}. But i wont do that.".format(member.name))173 await asyncio.sleep(120)174 await self.client.delete_message(msg1)175 if choice == 35:176 msg1 = await self.client.say("{0} tried to code a programm wich allowed him to creat a second Neko Public. Neko killed him befor he finished".format(member.name))177 await asyncio.sleep(120)178 await self.client.delete_message(msg1)179 if choice == 36:180 msg1 = await self.client.say("{0} was killed by AaBbCcDdEeFfGgHhIiJj ".format(member.name))181 await asyncio.sleep(120)182 await self.client.delete_message(msg1)183 if choice == 37:184 msg1 = await self.client.say("{0} was eaten by a giant fly.".format(member.name))185 await asyncio.sleep(120)186 await self.client.delete_message(msg1)187 if choice == 38:188 msg1 = await self.client.say("{0} was killed by a elephant herd ".format(member.name))189 await asyncio.sleep(120)190 await self.client.delete_message(msg1)191 if choice == 39:192 msg1 = await self.client.say("{0} met the sharknado. Guess what happened.".format(member.name))193 await asyncio.sleep(120)194 await self.client.delete_message(msg1)195 if choice == 40:196 msg1 = await self.client.say("{0} was walled up alive. Idk if he is still alive".format(member.name))197 await asyncio.sleep(120)198 await self.client.delete_message(msg1)199 if choice == 41:200 msg1 = await self.client.say("{0} tried to understand Apis...his mind blowed up.".format(member.name))201 await asyncio.sleep(120)202 await self.client.delete_message(msg1)203 if choice == 42:204 msg1 = await self.client.say("{0} has now the live target to wacht every video in the internet.I think tomorrow he is dead ".format(member.name))205 await asyncio.sleep(120)206 await self.client.delete_message(msg1)207 if choice == 43:208 msg1 = await self.client.say("{0} tried to understand Stephen Hawkins doctoral thesis. His mind exploded.".format(member.name))209 await asyncio.sleep(120)210 await self.client.delete_message(msg1)211 if choice == 44:212 msg1 = await self.client.say("{0} played grenade tennis with {1}. We have two deaths. ".format(member.name, p.name))213 await asyncio.sleep(120)214 await self.client.delete_message(msg1)215 if choice == 45:216 msg1 = await self.client.say("{0} was cleaning is gun, the gun was loaded and he hited the trigger.".format(member.name))217 await asyncio.sleep(120)218 await self.client.delete_message(msg1)219 if choice == 46:220 msg1 = await self.client.say("{0} played with a crocodile. The crocodile is now full. ".format(member.name))221 await asyncio.sleep(120)222 await self.client.delete_message(msg1)223 if choice == 47:224 msg1 = await self.client.say("{0} and {1} played together on the street. Both didnt saw the Bus. ".format(member.name, p.name))225 await asyncio.sleep(120)226 await self.client.delete_message(msg1)227 if choice == 48:228 msg1 = await self.client.say("{0} played CsGo in reallife. He got stabbed buy his teammate. ".format(member.name))229 await asyncio.sleep(120)230 await self.client.delete_message(msg1)231 if choice == 49:232 msg1 = await self.client.say("{0} was infected by an virus. A Worm lives in him but now he is dead.".format(member.name))233 await asyncio.sleep(120)234 await self.client.delete_message(msg1)235 if choice == 50:236 msg1 = await self.client.say("{0} and {1} played baseball with a grenade.".format(member.name, p.name))237 await asyncio.sleep(120)238 await self.client.delete_message(msg1)239 if choice == 51:240 msg1 = await self.client.say("{0} and {1} played football on a minefield.".format(member.name, p.name))241 await asyncio.sleep(120)242 await self.client.delete_message(msg1)243 if choice == 52:244 msg1 = await self.client.say("AIDS. {0} died of AIDS".format(member.name))245 await asyncio.sleep(120)246 await self.client.delete_message(msg1)247 if choice == 53:248 msg1 = await self.client.say("{0} heard loud heavy metal and that burst his eardrums. He is dead now".format(member.name))249 await asyncio.sleep(120)250 await self.client.delete_message(msg1)251 if choice == 54:252 msg1 = await self.client.say("{0} died because he has stolen a cookie from Neko.".format(member.name))253 await asyncio.sleep(120)254 await self.client.delete_message(msg1)255 if choice == 55:256 msg1 = await self.client.say("{0} died because he has stolen Nekos last Pizza. Stolen pizza is not funny, he deserved it. ".format(member.name))257 await asyncio.sleep(120)258 await self.client.delete_message(msg1)259 if choice == 56:260 msg1 = await self.client.say("{0} died because he insulted the Devs from Neko... ".format(member.name))261 await asyncio.sleep(120)262 await self.client.delete_message(msg1)263 if choice == 57:264 msg1 = await self.client.say("{0} died because he hated Metal. And I like it so he had to die. ".format(member.name))265 await asyncio.sleep(120)266 await self.client.delete_message(msg1)267 if choice == 58:268 msg1 = await self.client.say("{0} tried to hack Neko, but Neko killed him before...".format(member.name))269 await asyncio.sleep(120)270 await self.client.delete_message(msg1)271 if choice == 59:272 msg1 = await self.client.say("{0} died on a concert while he was crowedsurfing. Sad but True ".format(member.name))273 await asyncio.sleep(120)274 await self.client.delete_message(msg1)275 if choice == 60:276 msg1 = await self.client.say("{0} and {1} played together Mario party, {2} stole a Star from {3}. So {4} killed him. ".format(p.name, member.name, p.name, member.name, p.name))277 await asyncio.sleep(120)278 await self.client.delete_message(msg1)279 if choice == 61:280 msg1 = await self.client.say("{0} stepped on a Lego stone at night. The Pain was too much".format(member.name))281 await asyncio.sleep(120)282 await self.client.delete_message(msg1)283 if choice == 62:284 msg1 = await self.client.say("{0} toke some drugs and thought he can flight...".format(member.name))285 await asyncio.sleep(120)286 await self.client.delete_message(msg1)287 if choice == 63:288 msg1 = await self.client.say("{0} tried to survive over 5 days in Water. He he dissolved in the water. ".format(member.name))289 await asyncio.sleep(120)290 await self.client.delete_message(msg1)291 if choice == 64:292 msg1 = await self.client.say("{0} was thrown into an acid barrel by {1}".format(member.name, p.name))293 await asyncio.sleep(120)294 await self.client.delete_message(msg1)295 if choice == 65:296 msg1 = await self.client.say("{0} was thrown into an acid barrel by Neko".format(member.name))297 await asyncio.sleep(120)298 await self.client.delete_message(msg1)299 if choice ==66:300 msg1 = await self.client.say("{0} slipped on pedalos and broke his neck".format(member.name))301 await asyncio.sleep(120)302 await self.client.delete_message(msg1)303 if choice ==67:304 msg1 = await self.client.say("{0} was cleaning up is room but felt down the stairs".format(member.name))305 await asyncio.sleep(120)306 await self.client.delete_message(msg1)307 if choice ==68:308 msg1 = await self.client.say("{0} wanted to cook something but burned himself".format(member.name))309 await asyncio.sleep(120)310 await self.client.delete_message(msg1)311 if choice ==69:312 msg1 = await self.client.say("{0} died while watched Two Girls and... ".format(member.name))313 await asyncio.sleep(120)314 await self.client.delete_message(msg1)315 if choice ==70:316 msg1 = await self.client.say("{0} died because he forgot to change the acid with the water ".format(member.name))317 await asyncio.sleep(120)318 await self.client.delete_message(msg1)319 if choice ==71:320 msg1 = await self.client.say("{0} tried to outran Neko. He made it but just before the finish line he was killed by Neko ".format(member.name))321 await asyncio.sleep(120)322 await self.client.delete_message(msg1)323 if choice ==72:324 msg1 = await self.client.say("{0} died because he wanted to see every subreddit..that was too much for his hearth".format(member.name))325 await asyncio.sleep(120)326 await self.client.delete_message(msg1)327 if choice ==73:328 msg1 = await self.client.say("{0} died because he stole Nekos code...".format(member.name))329 await asyncio.sleep(120)330 await self.client.delete_message(msg1)331 if choice ==74:332 msg1 = await self.client.say("{0} got killed by AaBbCcDdEeFfGgHhIiJj".format(member.name))333 await asyncio.sleep(120)334 await self.client.delete_message(msg1)335 if choice ==75:336 msg1 = await self.client.say("{0} got killed by Niko".format(member.name))337 await asyncio.sleep(120)338 await self.client.delete_message(msg1)339 340 341def setup(client):
...
app.py
Source:app.py
...5253@bot.message_handler(content_types=['document'])54def delete_links_document(message):55 if (str(message.from_user.id) not in user0):56 bot.delete_message(message.chat.id, message.message_id)575859@bot.message_handler(content_types=['photo'])60def delete_links_photo(message):61 if (str(message.from_user.id) not in user0):62 bot.delete_message(message.chat.id, message.message_id)636465@bot.message_handler(content_types=['audio'])66def delete_links_audio(message):67 if (str(message.from_user.id) not in user0):68 bot.delete_message(message.chat.id, message.message_id)697071@bot.message_handler(content_types=['video'])72def delete_links_video(message):73 if (str(message.from_user.id) not in user0):74 bot.delete_message(message.chat.id, message.message_id)757677@bot.message_handler(content_types=['sticker'])78def delete_links_sticker(message):79 if (str(message.from_user.id) not in user0):80 bot.delete_message(message.chat.id, message.message_id)818283@bot.message_handler(content_types=['location'])84def delete_links_location(message):85 if (str(message.from_user.id) not in user0):86 bot.delete_message(message.chat.id, message.message_id)878889@bot.message_handler(content_types=['contact'])90def delete_links_contact(message):91 if (str(message.from_user.id) not in user0):92 bot.delete_message(message.chat.id, message.message_id)939495@bot.message_handler(content_types=['caption'])96def delete_links_caption(message):97 if (str(message.from_user.id) not in user0):98 bot.delete_message(message.chat.id, message.message_id)99100101@bot.message_handler(content_types=['venue'])102def delete_links_venue(message):103 if (str(message.from_user.id) not in user0):104 bot.delete_message(message.chat.id, message.message_id)105106107@bot.message_handler(func=lambda message: message.entities is not None)108def delete_links(message):109 if (str(message.from_user.id) not in user0):110 j = 0111 for entity in message.entities:112 j = j + 1113 if (j == 1):114 if (entity.type in ["url"]):115 bot.delete_message(message.chat.id, message.message_id)116 if (entity.type in ["text_link"]):117 bot.delete_message(message.chat.id, message.message_id)118 if (entity.type in ["pre"]):119 bot.delete_message(message.chat.id, message.message_id)120 if entity.type in ["hashtag"]:121 bot.delete_message(message.chat.id, message.message_id)122 if entity.type in ["email"]:123 bot.delete_message(message.chat.id, message.message_id)124 if entity.type in ["code"]:125 bot.delete_message(message.chat.id, message.message_id)126 if entity.type in ["bot_command"]:127 bot.delete_message(message.chat.id, message.message_id)128 if entity.type in ["bold"]:129 bot.delete_message(message.chat.id, message.message_id)130 if entity.type in ["mention"]:131 bot.delete_message(message.chat.id, message.message_id)132 if (entity.type in ["italic"]):133 bot.delete_message(message.chat.id, message.message_id)134135136@bot.message_handler(content_types=config.all_content_types)137def bot_new_message(message):138 if message.text:139 text_save = message.text140 elif message.caption:141 text_save = message.caption142 else:143 text_save = None144 if message.chat.type == 'private':145 try:146 if text_save.lower() in config.texts['add_chat_list']:147 keyboard = telebot.types.InlineKeyboardMarkup()148 button = telebot.types.InlineKeyboardButton(149 text='ÐÑбÑаÑÑ ÑаÑ...', url=f't.me/{bot_info.username}?startgroup=true')150 keyboard.add(button)151 return bot.send_message(message.chat.id, config.texts['add_chat_tutor'], reply_markup=keyboard)152 elif text_save.lower() in config.texts['help_list']:153 return bot.send_message(message.chat.id, config.texts['help_text'], reply_markup=def_keyboard())154 elif text_save.lower() in config.texts['add_antispam_list']:155 return bot.send_message(message.chat.id, config.texts['add_antispam_tutor'])156 except AttributeError:157 print("ÐÑибка AttributeError!")158 if not text_save:159 return160 text = text_save.translate(config.regexp).lower()161 text = config.emoji_pattern.sub(r'', text).split(' ')162 for word in text:163 result = scan_message(word)164 if result:165 try:166 bot.delete_message(message.chat.id, message.message_id)167 break168 except telebot.apihelper.ApiException:169 text = ''170 bot_chat_info = bot.get_chat_member(171 message.chat.id, bot_info.id)172 if not bot_chat_info.can_delete_messages:173 admins_ = bot.get_chat_administrators(message.chat.id)174 for admin in admins_:175 if admin.user.is_bot:176 pass177 if admin.can_promote_members or admin.status == 'creator':178 text += f'<a href="tg://user?id={admin.user.id}">{admin.user.first_name}</a>, '179 bot.send_message(180 message.chat.id, config.texts['no_perm'].format(text))
...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!