Best Python code snippet using localstack_python
bot.py
Source:bot.py
...132 chan = message.text.split()[1]133 if not PresentList.select().where(PresentList.ChannelID == chan):134 keyboard = types.InlineKeyboardMarkup(row_width=1)135 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in ['ð·ðº Ð ÑÑÑкий', 'ðºð¸ English', 'ðºð¿ УзбекÑкий']])136 bot.send_message(message.chat.id, get_message(lang, 'text60'), reply_markup=keyboard, parse_mode="Html")137138139 bot.send_message(UID, get_message(lang,"text24"))140 return141142 raffle = PresentList.get(PresentList.ChannelID == chan)143 ChannelName = raffle.ChannelName144 AboutPresent = raffle.AboutPresent145 DateClose = raffle.DateClose146 ButText = raffle.ButText147 PriceTicket = raffle.PriceTicket148 SubCheck = raffle.SubCheck149 WinnersCount = raffle.WinnersCount150 CountUser = len( AllMembersRaffle.select().where( AllMembersRaffle.ChannelName == ChannelName ) )151 a = NewUser.get(NewUser.USERID == UID)152 a.Selected = ChannelName153 a.save()154 msg = gettext(lang, 'text4', DateClose, AboutPresent, ChannelName, WinnersCount, PriceTicket, SubCheck, CountUser, ButText, '', '')155156 DateClose = raffle.DateClose157 keyboard = types.InlineKeyboardMarkup(row_width=1)158 keyboard.add(*[types.InlineKeyboardButton(text = f'({CountUser}) {name}', callback_data = name) for name in [get_message(lang, 'text38')]])159 bot.send_message(UID, msg,reply_markup=keyboard, parse_mode="Html")160161162 return163 keyboard = types.InlineKeyboardMarkup(row_width=1)164 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in ['ð·ðº Ð ÑÑÑкий', 'ðºð¸ English', 'ðºð¿ УзбекÑкий']])165 bot.send_message(message.chat.id, get_message(lang, 'text60'), reply_markup=keyboard, parse_mode="Html")166167 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)168 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text31')]])169 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text62')]])170171 bot.send_message(UID, get_message(lang, 'text1'), reply_markup=keyboard, parse_mode="Html")172173def editRaffle(message):174 text = message.text175 UID = message.chat.id176 lang = NewUser.get(NewUser.USERID == UID).lang177 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):178 bot.send_message(message.chat.id, get_message(lang,"text23"))179 return180 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)181 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text33'), get_message(lang, 'text34')]])182 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text35'),get_message(lang, 'text36')]])183 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text32'), get_message(lang, 'text37')]])184185 bot.send_message(UID, text, reply_markup = keyboard)186187 new = PresentList.get(PresentList.USERID == message.chat.id, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected)188 DateClose = new.DateClose189 ChannelName = new.ChannelName190 WinnersCount = new.WinnersCount191 SubCheck = new.SubCheck192 CountUser = len( AllMembersRaffle.select().where( AllMembersRaffle.ChannelName == ChannelName ) )193 ticket = new.PriceTicket194 AboutPresent = new.AboutPresent195 ButText = new.ButText196197 msg = gettext(lang, 'text1', DateClose, AboutPresent, ChannelName, WinnersCount, ticket, SubCheck, CountUser, ButText, '', '')198199 keyboard = types.InlineKeyboardMarkup(row_width=2)200 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text39'), get_message(lang, 'text40')]])201 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text41')]])202 if new.StatusRaffle == 'Published':203 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text42')]])204205 bot.send_message(message.chat.id, f'{msg}', reply_markup=keyboard, parse_mode="Html")206207208def creatRaffle(message):209 text = message.text210 UID = message.chat.id211 lang = NewUser.get(NewUser.USERID == UID).lang212213 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)214 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text33'), get_message(lang, 'text34')]])215 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text35'),get_message(lang, 'text36')]])216 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text32'), get_message(lang, 'text37')]])217218 bot.send_message(UID, text, reply_markup = keyboard)219 if text == get_message(lang, 'text27'):220 keyboard = types.ReplyKeyboardRemove()221 bot.send_message(UID, message.text, reply_markup=keyboard, parse_mode="Html")222223 my_chat = []224 [ my_chat.append(name.ChannelName) for name in ChannelList.select().where(ChannelList.USERID == UID)]225 226 keyboard = types.InlineKeyboardMarkup(row_width=1)227 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text26')]])228 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in my_chat])229230 bot.send_message(UID, get_message(lang, 'text2'), reply_markup=keyboard, parse_mode="Html")231 return232233 else:234 if not PresentList.row_exists__(UID, NewUser.get(NewUser.USERID == message.chat.id).Selected):235 PresentList.creat_row(UID)236 rf = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == '')237 rf.ChannelName = NewUser.get(NewUser.USERID == message.chat.id).Selected238 rf.ChannelID = ChannelList.get(ChannelList.USERID == message.chat.id, ChannelList.ChannelName == rf.ChannelName).ChannelID239 rf.AboutPresent = text240 rf.PriceTicket = 1241 rf.save()242243 new = PresentList.get(PresentList.USERID == message.chat.id, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected)244 DateClose = new.DateClose245 ChannelName = new.ChannelName246 WinnersCount = new.WinnersCount247 SubCheck = new.SubCheck248 CountUser = len( AllMembersRaffle.select().where( AllMembersRaffle.ChannelName == ChannelName ) )249 ticket = new.PriceTicket250 AboutPresent = new.AboutPresent251 ButText = new.ButText252253 msg = gettext(lang, 'text3', DateClose, AboutPresent, ChannelName, WinnersCount, ticket, SubCheck, CountUser, ButText, '', '')254255 keyboard = types.InlineKeyboardMarkup(row_width=2)256 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text39'), get_message(lang, 'text40')]])257 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text41')]])258 if new.StatusRaffle == 'Published':259 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text42')]])260261 bot.send_message(message.chat.id, f'{msg}', reply_markup=keyboard, parse_mode="Html")262263264def SendRaffle(message):265 UID = message.chat.id266 text = message.text267 lang = NewUser.get(NewUser.USERID == UID).lang268 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)269 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text33'), get_message(lang, 'text34')]])270 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text35'),get_message(lang, 'text36')]])271 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text32'), get_message(lang, 'text37')]])272 bot.send_message(UID, text, reply_markup = keyboard)273274 new = PresentList.get(PresentList.USERID == message.chat.id, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected)275 DateClose = new.DateClose276 ChannelName = new.ChannelName277 WinnersCount = new.WinnersCount278 SubCheck = new.SubCheck279 CountUser = len( AllMembersRaffle.select().where( AllMembersRaffle.ChannelName == ChannelName ) )280 ticket = new.PriceTicket281 AboutPresent = new.AboutPresent282 ButText = new.ButText283 284 msg = gettext(lang, 'text3', DateClose, AboutPresent, ChannelName, WinnersCount, ticket, SubCheck, CountUser, ButText, '', '')285 keyboard = types.InlineKeyboardMarkup(row_width=2)286 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text39'), get_message(lang, 'text40')]])287 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text41')]])288 if new.StatusRaffle == 'Published':289 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text42')]])290 bot.send_message(chat_id = UID, text = msg, reply_markup=keyboard, parse_mode="Html")291292293294def NewPrice(message):295 price = message.text296 UID = message.chat.id297 lang = NewUser.get(NewUser.USERID == UID).lang298 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):299 bot.send_message(message.chat.id, get_message(lang,"text23"))300 return301 if price == get_message(lang, 'text27'):302 SendRaffle(message)303 return304305306 if price.isdigit() == True:307 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )308 m.PriceTicket = price309 m.save()310311 SendRaffle(message)312313 else:314 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)315 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])316 sent = bot.send_message(UID, f'{get_message(lang, "text43")}\n{get_message(lang,"text8")}', reply_markup=keyboard, parse_mode="Html")317 bot.register_next_step_handler(sent, NewPrice) 318319def NewTextRaffle(message):320 text = message.text321 UID = message.chat.id322 lang = NewUser.get(NewUser.USERID == UID).lang323 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):324 bot.send_message(message.chat.id, get_message(lang,"text23"))325 return326 if text == get_message(lang, 'text27'):327 SendRaffle(message)328 return329330 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )331 m.AboutPresent = text332 m.save()333 SendRaffle(message)334335def NewTextButton(message):336 text = message.text337 UID = message.chat.id338 lang = NewUser.get(NewUser.USERID == UID).lang339 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):340 bot.send_message(message.chat.id, get_message(lang,"text23"))341 return342 if text == get_message(lang, 'text27'):343 SendRaffle(message)344 return345346 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )347 m.ButText = text348 m.save()349 SendRaffle(message)350351def NewYear(message):352 text = message.text353 UID = message.chat.id354 lang = NewUser.get(NewUser.USERID == UID).lang355 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):356 bot.send_message(message.chat.id, get_message(lang,"text23"))357 return358 if text == get_message(lang, 'text27'):359 SendRaffle(message)360 return361 format = "%Y"362 if text.isdigit() == True and int(text) >= int(datetime.now(timezone('Etc/GMT+3')).astimezone(timezone('EET')).strftime(format)):363 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )364 date = m.DateClose365 date = date.replace(m.DateClose.split('-')[0], text)366 m.DateClose = date367 m.save()368 SendRaffle(message)369 else:370 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)371 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])372 sent = bot.send_message(UID, f'{get_message(lang, "text100")}', reply_markup=keyboard, parse_mode="Html")373 bot.register_next_step_handler(sent, NewYear) 374375def NewMonth(message):376 text = message.text377 UID = message.chat.id378 lang = NewUser.get(NewUser.USERID == UID).lang379 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):380 bot.send_message(message.chat.id, get_message(lang,"text23"))381 return382 if text == get_message(lang, 'text27'):383 SendRaffle(message)384 return385 format = "%m"386 if text.isdigit() == True and int(text) >= int(datetime.now(timezone('Etc/GMT+3')).astimezone(timezone('EET')).strftime(format)) and int(text) <= 12 and int(text) >= 1:387 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )388 date = m.DateClose389 date = date.replace(m.DateClose.split('-')[1], text)390 m.DateClose = date391 m.save()392 SendRaffle(message)393 else:394 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)395 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])396 sent = bot.send_message(UID, f'{get_message(lang, "text100")}', reply_markup=keyboard, parse_mode="Html")397 bot.register_next_step_handler(sent, NewMonth) 398399400def NewDay(message):401 text = message.text402 UID = message.chat.id403 lang = NewUser.get(NewUser.USERID == UID).lang404 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):405 bot.send_message(message.chat.id, get_message(lang,"text23"))406 return407 if text == get_message(lang, 'text27'):408 SendRaffle(message)409 return410 format = "%d"411 if text.isdigit() == True and int(text) >= int(datetime.now(timezone('Etc/GMT+3')).astimezone(timezone('EET')).strftime(format)) and int(text) <= 31 and int(text) >= 1:412 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )413 date = m.DateClose414 date = date.replace(m.DateClose.split('-')[2].split(' ')[0], text)415 m.DateClose = date416 m.save()417 SendRaffle(message)418 else:419 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)420 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])421 sent = bot.send_message(UID, f'{get_message(lang, "text100")}', reply_markup=keyboard, parse_mode="Html")422 bot.register_next_step_handler(sent, NewDay) 423424425def NewHour(message):426 text = message.text427 UID = message.chat.id428 lang = NewUser.get(NewUser.USERID == UID).lang429 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):430 bot.send_message(message.chat.id, get_message(lang,"text23"))431 return432 if text == get_message(lang, 'text27'):433 SendRaffle(message)434 return435 format = "%d"436 if text.isdigit() == True and int(text) >= int(datetime.now(timezone('Etc/GMT+3')).astimezone(timezone('EET')).strftime(format)) and int(text) <= 24 and int(text) >= 1:437 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )438 date = m.DateClose439 date = date.replace(m.DateClose.split(' ')[1].split(':')[0], text)440 m.DateClose = date441 m.save()442 SendRaffle(message)443 else:444 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)445 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])446 sent = bot.send_message(UID, f'{get_message(lang, "text100")}', reply_markup=keyboard, parse_mode="Html")447 bot.register_next_step_handler(sent, NewDay) 448449def NewMin(message):450 text = message.text451 UID = message.chat.id452 lang = NewUser.get(NewUser.USERID == UID).lang453 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):454 bot.send_message(message.chat.id, get_message(lang,"text23"))455 return456 if text == get_message(lang, 'text27'):457 SendRaffle(message)458 return459 format = "%d"460 if text.isdigit() == True and int(text) >= int(datetime.now(timezone('Etc/GMT+3')).astimezone(timezone('EET')).strftime(format)) and int(text) <= 60 and int(text) >= 1:461 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )462 date = m.DateClose463 date = date.replace(m.DateClose.split(' ')[1].split(':')[1], text)464 m.DateClose = date465 m.save()466 SendRaffle(message)467 else:468 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)469 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])470 sent = bot.send_message(UID, f'{get_message(lang, "text100")}', reply_markup=keyboard, parse_mode="Html")471 bot.register_next_step_handler(sent, NewMin) 472473474475@bot.message_handler(content_types=["text"])476def key(message):477 UID = message.chat.id478 lang = NewUser.get(NewUser.USERID == UID).lang479480 if message.text == get_message(lang, 'text37'):481 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):482 bot.send_message(message.chat.id, get_message(lang,"text23"))483 return484485 chn_name = NewUser.get(NewUser.USERID == UID).Selected486 raffle = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == chn_name)487488 if raffle.StatusRaffle == 'Published':489 bot.send_message(UID, get_message(lang,"text16"))490 return491492 raffle.StatusRaffle = 'Published'493 raffle.save()494495 send_user = ChannelList.get(ChannelList.ChannelName == chn_name).ChannelID496497 try:498499 keyboard = types.InlineKeyboardMarkup(row_width=2)500 keyboard.add(*[types.InlineKeyboardButton(text = name, url = f'https://t.me/{bot.get_me().username}?start={raffle.ChannelID}') for name in [f'{raffle.ButText}']])501502 bot.send_message(send_user, f'{raffle.AboutPresent}', reply_markup=keyboard, parse_mode="Html")503 bot.send_message(UID, get_message(lang,"text15"))504 except:505 bot.send_message(UID, get_message(lang,"text7"))506507508509 if message.text == get_message(lang, 'text35'):510 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):511 bot.send_message(message.chat.id, get_message(lang,"text23"))512 return513514 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)515 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])516 sent = bot.send_message(UID, get_message(lang,"text8"), reply_markup=keyboard, parse_mode="Html")517 bot.register_next_step_handler(sent, NewPrice)518519 if message.text == get_message(lang, 'text33'):520 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):521 bot.send_message(message.chat.id, get_message(lang,"text23"))522 return523 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)524 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])525 sent = bot.send_message(UID, get_message(lang,"text9"), reply_markup=keyboard, parse_mode="Html")526 bot.register_next_step_handler(sent, NewTextRaffle)527528 if message.text == get_message(lang, 'text36'):529 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):530 bot.send_message(message.chat.id, get_message(lang,"text23"))531 return532 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)533 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])534 sent = bot.send_message(UID, get_message(lang,"text10"), reply_markup=keyboard, parse_mode="Html")535 bot.register_next_step_handler(sent, NewTextButton)536537 if message.text == get_message(lang, 'text65'):538 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)539 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])540 sent = bot.send_message(UID, get_message(lang, 'text70'), reply_markup=keyboard, parse_mode="Html")541 bot.register_next_step_handler(sent, NewYear)542543 if message.text == get_message(lang, 'text66'):544 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)545 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])546 sent = bot.send_message(UID, get_message(lang, 'text70'), reply_markup=keyboard, parse_mode="Html")547 bot.register_next_step_handler(sent, NewMonth)548549550 if message.text == get_message(lang, 'text67'):551 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)552 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])553 sent = bot.send_message(UID, get_message(lang, 'text70'), reply_markup=keyboard, parse_mode="Html")554 bot.register_next_step_handler(sent, NewDay)555556557 if message.text == get_message(lang, 'text68'):558 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)559 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])560 sent = bot.send_message(UID, get_message(lang, 'text70'), reply_markup=keyboard, parse_mode="Html")561 bot.register_next_step_handler(sent, NewHour)562563564 if message.text == get_message(lang, 'text69'):565 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)566 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])567 sent = bot.send_message(UID, get_message(lang, 'text70'), reply_markup=keyboard, parse_mode="Html")568 bot.register_next_step_handler(sent, NewMin)569570571 if message.text == get_message(lang, 'text34'):572 if not PresentList.select().where(PresentList.USERID==UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == message.chat.id).Selected):573 bot.send_message(message.chat.id, get_message(lang,"text23"))574 return575576 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)577 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text65'),get_message(lang, 'text66'),get_message(lang, 'text67'),get_message(lang, 'text68'),get_message(lang, 'text69'),get_message(lang, 'text101') ]])578 bot.send_message(UID, f'{get_message(lang,"text11")}', reply_markup=keyboard, parse_mode="Html")579 #bot.register_next_step_handler(sent, NewDate)580581 if message.text == get_message(lang, 'text62'):582 keyboard = types.InlineKeyboardMarkup(row_width=1)583 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in ['ð·ðº Ð ÑÑÑкий', 'ðºð¸ English', 'ðºð¿ УзбекÑкий']])584 bot.send_message(message.chat.id, get_message(lang, 'text60'), reply_markup=keyboard, parse_mode="Html")585586587 if message.text == get_message(lang, 'text32'):588589 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)590 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text31')]])591 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text62')]])592593 bot.send_message(UID, get_message(lang, 'text1'), reply_markup=keyboard, parse_mode="Html")594595 if message.text == get_message(lang, 'text29'):596597 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)598 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])599600 sent = bot.send_message(UID, get_message(lang,'text13'), reply_markup=keyboard, parse_mode="Html")601 bot.register_next_step_handler(sent, creatRaffle)602603 if message.text == get_message(lang, 'text30') or message.text == get_message(lang, 'text101'):604 editRaffle(message)605606607 if message.text == get_message(lang, 'text31'):608 keyboard = types.ReplyKeyboardRemove()609 bot.send_message(UID, message.text, reply_markup=keyboard, parse_mode="Html")610611 my_chat = []612 [ my_chat.append(name.ChannelName) for name in ChannelList.select().where(ChannelList.USERID == UID)]613 614 keyboard = types.InlineKeyboardMarkup(row_width=1)615 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text26')]])616 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in my_chat])617618 bot.send_message(UID, get_message(lang, 'text2'), reply_markup=keyboard, parse_mode="Html")619620621@bot.callback_query_handler(func=lambda c: True)622def inline(x):623 UID = x.message.chat.id624 lang = NewUser.get(NewUser.USERID == UID).lang625 MESSAGE = x.message.message_id626627 if x.data in ['ð·ðº Ð ÑÑÑкий', 'ðºð¸ English', 'ðºð¿ УзбекÑкий']:628 if x.data == 'ð·ðº Ð ÑÑÑкий':629 a = NewUser.get(NewUser.USERID == UID)630 a.lang = 'ru'631 a.save()632633634 if x.data == 'ðºð¸ English':635 a = NewUser.get(NewUser.USERID == UID)636 a.lang = 'eng'637 a.save()638639 if x.data == 'ðºð¿ УзбекÑкий':640 a = NewUser.get(NewUser.USERID == UID)641 a.lang = 'uz'642 a.save()643644 lang = NewUser.get(NewUser.USERID == UID).lang645 bot.delete_message(chat_id = UID, message_id = MESSAGE)646 keyboard = types.ReplyKeyboardRemove()647 bot.send_message(UID, x.data, reply_markup=keyboard, parse_mode="Html")648649 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)650 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text31')]])651 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text62')]])652 bot.send_message(UID, get_message(lang, 'text1'), reply_markup=keyboard, parse_mode="Html")653654655 if x.data == get_message(lang, 'text42'):656 if not PresentList.select().where(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected):657 bot.edit_message_text(chat_id = UID, message_id = MESSAGE, text = get_message(lang,"text21"))658 return659660661 _all_ = AllMembersRaffle.select().where(AllMembersRaffle.ChannelName == NewUser.get(NewUser.USERID == UID).Selected)662 WinnersCount = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected).WinnersCount663 chaname = NewUser.get(NewUser.USERID == UID)664 import random665 winners = []666 while True:667 if len(_all_) == 0:668 bot.send_message(UID, get_message(lang, 'text25'), parse_mode = 'Html')669 break670 countAll = len(_all_)671 ran = random.randrange(countAll)672 if _all_[ran].USERID not in winners:673 winners.append(_all_[ran].USERID)674 if len(winners) == int(WinnersCount) or len(_all_) < int(WinnersCount):675 break676677 for winners in winners:678 usname = bot.get_chat_member(ChannelList.get(ChannelList.USERID == UID, ChannelList.ChannelName == chaname.Selected).ChannelID, winners)679 username = usname.user.first_name680 AboutPresent = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == chaname.Selected).AboutPresent681 code = AllMembersRaffle.get(AllMembersRaffle.USERID == winners, AllMembersRaffle.ChannelName == NewUser.get(NewUser.USERID == UID).Selected).UNtoken682683 msg = gettext(lang, 'text2', UID, AboutPresent, 'ChannelName', 'WinnersCount', 'ticket', 'SubCheck', 'CountUser', 'ButText', username, code)684 bot.send_message(UID, msg, parse_mode = 'Html')685 bot.send_message(winners, msg, parse_mode = 'Html')686687 cat = PresentList.select().where(PresentList.USERID == UID, PresentList.ChannelName == chaname.Selected)688 for car in cat:689 car.delete_instance()690 car.save()691692 cat = AllMembersRaffle.select().where(AllMembersRaffle.ChannelName == chaname.Selected)693 for car in cat:694 car.delete_instance()695 car.save()696697 if x.data == get_message(lang, 'text38'):698 if AllMembersRaffle.select().where(AllMembersRaffle.USERID == UID, AllMembersRaffle.ChannelName == NewUser.get(NewUser.USERID == UID).Selected):699 bot.send_message(UID, get_message(lang,"text20"))700 return701702 raffle = PresentList.get(PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected)703 ChannelName = raffle.ChannelName704 AboutPresent = raffle.AboutPresent705 ButText = raffle.ButText706 PriceTicket = raffle.PriceTicket707 SubCheck = raffle.SubCheck708 WinnersCount = raffle.WinnersCount709 CountUser = len( AllMembersRaffle.select().where( AllMembersRaffle.ChannelName == ChannelName ) )710 if SubCheck == 'On':711 status = ['creator', 'administrator', 'member']712 if bot.get_chat_member(chat_id=ChannelList.get(ChannelList.ChannelID == raffle.ChannelID).ChannelID, user_id=x.message.chat.id).status in status:713 714 if int(PriceTicket) == 0:715 if not AllMembersRaffle.row_exists(UID, NewUser.get(NewUser.USERID == UID).Selected):716 AllMembersRaffle.creat_row(UID, NewUser.get(NewUser.USERID == UID).Selected)717718 import random719720 chars = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'721 for n in range(1):722 password =''723 for i in range(15):724 password += random.choice(chars)725726727 a = AllMembersRaffle.get(AllMembersRaffle.USERID == UID)728 a.UNtoken = password729 a.save()730731 bot.send_message(UID, f'{get_message(lang,"text18")}\n\n{get_message(lang,"text19")}:')732 bot.send_message(UID, f'{password}')733 return734735 #keyboard = types.InlineKeyboardMarkup(row_width=2)736 #keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in ['Visa/MasterCard']])737 #bot.edit_message_text(chat_id = UID, message_id = MESSAGE, text = , reply_markup = keyboard, parse_mode = 'Html')738 739 PRICE = [ 740 types.LabeledPrice(label='Raffle', amount= 100 * int(PriceTicket) ),741 ]742743 bot.send_invoice(x.message.chat.id,744 title=ChannelName,745 description={AboutPresent},746 provider_token= token_pay,747 currency= 'usd',748 prices= PRICE,749 start_parameter='time-machine-example',750 invoice_payload = 'asdsad')751752753 754 else:755756 keyboard = types.InlineKeyboardMarkup(row_width=2)757 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text38')]])758 msg = gettext(lang, 'text5', 'DateClose', AboutPresent, ChannelList.get(ChannelList.ChannelID == raffle.ChannelID).ChannelName, WinnersCount, 'ticket', SubCheck, CountUser, ButText, '', '')759 bot.edit_message_text(chat_id = UID, message_id = MESSAGE,text = msg, reply_markup = keyboard, parse_mode = 'Html')760 761762 else:763 if int(PriceTicket) == 0:764 if not AllMembersRaffle.row_exists(UID, NewUser.get(NewUser.USERID == UID).Selected):765 AllMembersRaffle.creat_row(UID, NewUser.get(NewUser.USERID == UID).Selected)766767 import random768769 chars = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'770 for n in range(1):771 password =''772 for i in range(15):773 password += random.choice(chars)774775776 a = AllMembersRaffle.get(AllMembersRaffle.USERID == UID)777 a.UNtoken = password778 a.save()779780 bot.send_message(UID, f'{get_message(lang,"text18")}\n\n{get_message(lang,"text19")}:')781 bot.send_message(UID, f'{password}')782 return783784785 PRICE = [ 786 types.LabeledPrice(label='Raffle', amount= 100 * int(PriceTicket) ),787 ]788789 bot.send_invoice(x.message.chat.id,790 title=ChannelName,791 description={AboutPresent},792 provider_token= token_pay,793 currency= 'usd',794 prices= PRICE,795 start_parameter='time-machine-example',796 invoice_payload = 'asdsad')797798799 if x.data == get_message(lang, 'text62'):800 keyboard = types.InlineKeyboardMarkup(row_width=1)801 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in ['ð·ðº Ð ÑÑÑкий', 'ðºð¸ English', 'ðºð¿ УзбекÑкий']])802 bot.send_message(UID, get_message(lang, 'text60'), reply_markup=keyboard, parse_mode="Html")803804 if x.data == get_message(lang, 'text39') or x.data == get_message(lang, 'text40') or x.data == get_message(lang, 'text41'):805 m = PresentList.get(PresentList.USERID == UID, PresentList.ChannelName == NewUser.get(NewUser.USERID == UID).Selected )806 if x.data == get_message(lang, 'text39'):807 808 if m.WinnersCount == '1':809 return 810 else:811 new_m = int(m.WinnersCount) - 1812 m.WinnersCount = new_m813 m.save()814815 if x.data == get_message(lang, 'text40'):816 new_m = int(m.WinnersCount) + 1817 m.WinnersCount = new_m818 m.save()819820 if x.data == get_message(lang, 'text41'):821 if m.SubCheck == 'On':822 m.SubCheck = 'Off'823 m.save()824 elif m.SubCheck == 'Off':825 m.SubCheck = 'On'826 m.save()827828 new = PresentList.get(PresentList.USERID == x.message.chat.id, PresentList.ChannelName == NewUser.get(NewUser.USERID == x.message.chat.id).Selected)829 DateClose = new.DateClose830 ChannelName = new.ChannelName831 WinnersCount = new.WinnersCount832 SubCheck = new.SubCheck833 CountUser = len( AllMembersRaffle.select().where( AllMembersRaffle.ChannelName == ChannelName ) )834 ticket = new.PriceTicket835 AboutPresent = new.AboutPresent836 ButText = new.ButText837 838 msg = gettext(lang, 'text3', DateClose, AboutPresent, ChannelName, WinnersCount, ticket, SubCheck, CountUser, ButText, '', '')839 keyboard = types.InlineKeyboardMarkup(row_width=2)840 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text39'), get_message(lang, 'text40')]])841 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text41')]])842 if new.StatusRaffle == 'Published':843 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text42')]])844 bot.edit_message_text(chat_id = UID, message_id = MESSAGE, text = msg, reply_markup=keyboard, parse_mode="Html")845846847848849 if x.data == get_message(lang, 'text26'):850851 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)852 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text27')]])853 854 sent = bot.send_message(chat_id = UID, text = get_message(lang,"text6"), reply_markup=keyboard, parse_mode="Html")855 bot.register_next_step_handler(sent, AddChat)856857 my_channel = []858 for name in ChannelList.select().where(ChannelList.USERID == UID):859 if name.ChannelName not in my_channel:860 my_channel.append(name.ChannelName)861862863 if x.data in my_channel:864 sel = NewUser.get(NewUser.USERID == UID)865 sel.Selected = x.data866 sel.save()867868869 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=1)870 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text29')]])871 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text30')]])872 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text32')]])873874 bot.send_message(chat_id = UID, text = f'{ get_message(lang,"text5") } {x.data}', reply_markup=keyboard, parse_mode="Html")875876877def AddChat(message):878 UID = message.chat.id879 lang = NewUser.get(NewUser.USERID == UID).lang880 if message.text == get_message(lang, 'text27'):881 keyboard = types.ReplyKeyboardRemove()882 bot.send_message(UID, message.text, reply_markup=keyboard, parse_mode="Html")883884 my_chat = []885 [ my_chat.append(name.ChannelName) for name in ChannelList.select().where(ChannelList.USERID == UID)]886 887 keyboard = types.InlineKeyboardMarkup(row_width=1)888 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text26')]])889 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in my_chat])890891 bot.send_message(UID, get_message(lang,'text2'), reply_markup=keyboard, parse_mode="Html")892 return893894 if message.forward_from_chat != None:895 ChannelID = message.forward_from_chat.id896 ChannelName = message.forward_from_chat.title897898 if not ChannelList.row_exists(UID, ChannelID, ChannelName):899 ChannelList.creat_row(UID, ChannelID, ChannelName)900901 keyboard = types.ReplyKeyboardRemove()902 bot.send_message(UID, str(get_message(lang,'text3')) +' '+str(ChannelName), reply_markup=keyboard, parse_mode="Html")903 my_chat = []904 [ my_chat.append(name.ChannelName) for name in ChannelList.select().where(ChannelList.USERID == UID)]905 906 keyboard = types.InlineKeyboardMarkup(row_width=1)907 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in [get_message(lang, 'text26')]])908 keyboard.add(*[types.InlineKeyboardButton(text = name, callback_data = name) for name in my_chat])909910 bot.send_message(UID, get_message(lang,'text2'), reply_markup=keyboard, parse_mode="Html")911912 else:913 keyboard = types.ReplyKeyboardRemove()914 bot.send_message(UID, get_message(lang, 'text28'), reply_markup=keyboard, parse_mode="Html")915916 keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)917 keyboard.add(*[types.KeyboardButton(name) for name in [get_message(lang, 'text31')]])918 bot.send_message(UID, get_message(lang,'text4'), reply_markup=keyboard, parse_mode="Html")919920921922923924@bot.pre_checkout_query_handler(func=lambda query: True)925def process_pre_checkout_query(pre_checkout_query: types.PreCheckoutQuery):926 bot.answer_pre_checkout_query(pre_checkout_query.id, ok=True)927928@bot.message_handler(content_types=['successful_payment'])929def process_successful_payment(message):930 UID = message.chat.id931 lang = NewUser.get(NewUser.USERID == UID).lang932 if not AllMembersRaffle.row_exists(UID, NewUser.get(NewUser.USERID == UID).Selected):933 AllMembersRaffle.creat_row(UID, NewUser.get(NewUser.USERID == UID).Selected)934935 import random936937 chars = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'938 for n in range(1):939 password =''940 for i in range(15):941 password += random.choice(chars)942943944 a = AllMembersRaffle.get(AllMembersRaffle.USERID == UID)945 a.UNtoken = password946 a.save()947948 bot.send_message(UID, f'{get_message(lang,"text18")}\n\n{get_message(lang,"text19")}:')949 bot.send_message(UID, f'{password}')950951952953def gettext(lang, key, DateClose, AboutPresent, ChannelName, WinnersCount, ticket, SubCheck, CountUser, ButText, username, code):954 dictionary = {955 'text1': f'{get_message(lang, "text14")}\n{get_message(lang, "text44")}: {DateClose}\n\n{get_message(lang, "text45")}: {AboutPresent}\n{get_message(lang, "text46")}: {ChannelName}\n{get_message(lang, "text47")}: {WinnersCount}\n{get_message(lang, "text48")}: {ticket} $\n{get_message(lang, "text49")}: {SubCheck}\n{get_message(lang, "text50")}: ({CountUser}) {ButText}',956 'text2': f'{get_message(lang, "text45")}: {AboutPresent}\n\n{get_message(lang, "text51")}: <a href="tg://user?id={DateClose}">{username}</a>\n{get_message(lang, "text52")}: <code>{ code }</code>',957 'text3': f'{get_message(lang, "text14")}\n{get_message(lang, "text44")}: {DateClose}\n\n{get_message(lang, "text45")}: {AboutPresent}\n{get_message(lang, "text46")}: {ChannelName}\n{get_message(lang, "text47")}: {WinnersCount}\n{get_message(lang, "text48")}: {ticket} $\n{get_message(lang, "text49")}: {SubCheck}\n{get_message(lang, "text50")}: ({CountUser}) {ButText}',958 'text4': f'{get_message(lang, "text44")}: {DateClose}\n{get_message(lang, "text48")}: {ticket}\n{get_message(lang, "text53")}: {WinnersCount}\n\n{AboutPresent}',959 'text5': f'âï¸{get_message(lang,"text17")}: {ChannelName}\n\n{AboutPresent}',960 }961 return dictionary[key]962963964965if __name__ == '__main__':
...
tipbot.py
Source:tipbot.py
...26 return {'method': 'help'}27 if re.match('^(followme|ãã©ãã¼ãã¼|ãã©ãã¼ãã¦)', ''.join([word.lower() for word in words])):28 return {'method': 'follow'}29 return {'method': None}30def get_message(text: str, *screen_names: str) -> str:31 for screen_name in screen_names[::-1]:32 text = f'@{screen_name} ' + text33 return '\n'.join([text, '', ''.join([random.choice(string.ascii_letters) for i in range(4)])])34def Decimal_to_str(d: Decimal) -> str:35 reverse_s = f'{d:.8f}'[::-1]36 return_s = reverse_s37 for s in reverse_s:38 if s == '0':39 return_s = return_s[1:]40 continue41 if s == '.':42 return_s = return_s[1:]43 break44 return_s = return_s[::-1]45 return return_s46def execute(text: str, user_id: str, screen_name: str, name: str, from_tweet: bool) -> Optional[str]:47 account = 'twitter-' + user_id48 name = name.split('@')[0] if not name.startswith('@') else name49 command = get_command(text)50 if command['method'] == None:51 return None52 if command['method'] == 'tip':53 if len(command['params']) < 2:54 text = 'tipkotoneã®ä½¿ãæ¹ãã確èªãã ããï¼ https://github.com/akarinS/tipkotone/blob/master/README.md'55 return get_message(text, screen_name) if from_tweet else get_message(text)56 if re.match('^@', command['params'][0]):57 to_screen_name = command['params'][0][1:]58 str_amount = command['params'][1]59 elif re.match('^@', command['params'][1]):60 to_screen_name = command['params'][1][1:]61 str_amount = command['params'][0]62 else:63 text = 'å®å
ãééã£ã¦ãã¾ãã»ã»ã»'64 return get_message(text, screen_name) if from_tweet else get_message(text)65 if to_screen_name == screen_name:66 text = 'èªèº«ã«ã¯æãéã§ãã¾ããã»ã»ã»'67 return get_message(text, screen_name) if from_tweet else get_message(text)68 if to_screen_name == BOTSCREENNAME:69 to_account = 'FREE'70 else:71 to_user = twitter.user(to_screen_name)72 if to_user.get('error') is not None:73 text = 'å®å
ãè¦ã¤ããã¾ããã§ããã»ã»ã»'74 return get_message(text, screen_name) if from_tweet else get_message(text)75 to_user_id = to_user['id_str']76 to_account = 'twitter-' + to_user_id77 to_name = to_user['name']78 to_name = to_name.split('@')[0] if not to_name.startswith('@') else name79 result = aw.move(account, to_account, str_amount)80 if result == 'wrong':81 text = 'ä¸æ£ãªéé¡ã§ãã»ã»ã»'82 return get_message(text, screen_name) if from_tweet else get_message(text)83 elif result == 'few':84 text = 'éé¡ãå°ãããã§ãã»ã»ã»'85 return get_message(text, screen_name) if from_tweet else get_message(text)86 elif result == 'insufficient':87 text = 'æ®é«ã足ãã¾ããã»ã»ã»'88 return get_message(text, screen_name) if from_tweet else get_message(text)89 amount = Decimal_to_str(result)90 if to_screen_name == BOTSCREENNAME:91 text = f'{amount}KOTO å¯ä»ãã¦ããã ããããã¨ããããã¾ãï¼'92 return get_message(text, screen_name) if from_tweet else get_message(text)93 text = f'{name}ãããã {to_name}ãã㸠ãå¿ä»ãã§ãï¼ {amount}KOTO'94 return get_message(text, screen_name, to_screen_name) if from_tweet else get_message(text)95 if command['method'] == 'balance':96 balance, confirming_balance = aw.get_account_balance(account)97 balance = Decimal_to_str(balance)98 if confirming_balance == 0:99 text = f'{name}ããã®æ®é«ã¯ {balance}KOTO ã§ãï¼'100 else:101 confirming_balance = Decimal_to_str(confirming_balance)102 text = f'{name}ããã®æ®é«ã¯ {balance}KOTO (+{confirming_balance}KOTO æ¿èªä¸) ã§ãï¼'103 return get_message(text, screen_name) if from_tweet else get_message(text)104 if command['method'] == 'deposit':105 address = aw.get_account_address(account)106 text = f'{address} ã«ééãã¦ãã ããï¼'107 return get_message(text, screen_name) if from_tweet else get_message(text)108 if command['method'] == 'withdraw':109 if len(command['params']) < 2:110 text = 'tipkotoneã®ä½¿ãæ¹ãã確èªãã ããï¼ https://github.com/akarinS/tipkotone/blob/master/README.md'111 return get_message(text, screen_name) if from_tweet else get_message(text)112 if re.match('^(k|jz)', command['params'][0]):113 address = command['params'][0]114 str_amount = command['params'][1]115 elif re.match('^(k|jz)', command['params'][1]):116 address = command['params'][1]117 str_amount = command['params'][0]118 else:119 text = 'ã¢ãã¬ã¹ãééã£ã¦ãã¾ãã»ã»ã»'120 return get_message(text, screen_name) if from_tweet else get_message(text)121 if not coinrpc.call('validateaddress', address)['isvalid']:122 text = 'ã¢ãã¬ã¹ãééã£ã¦ãã¾ãã»ã»ã»'123 return get_message(text, screen_name) if from_tweet else get_message(text)124 result = aw.add_withdrawal_request(account, address, str_amount)125 if result == 'wrong':126 text = 'ä¸æ£ãªéé¡ã§ãã»ã»ã»'127 return get_message(text, screen_name) if from_tweet else get_message(text)128 elif result == 'few':129 text = 'éé¡ãå°ãããã§ãã»ã»ã»'130 return get_message(text, screen_name) if from_tweet else get_message(text)131 elif result == 'insufficient':132 text = 'æ®é«ã足ãã¾ããã»ã»ã»'133 return get_message(text, screen_name) if from_tweet else get_message(text)134 amount = Decimal_to_str(result)135 text = f'{amount}KOTO ã®åºéãªã¯ã¨ã¹ããåãä»ãã¾ããï¼'136 return get_message(text, screen_name) if from_tweet else get_message(text)137 if command['method'] == 'help':138 text = 'tipkotoneã®ä½¿ãæ¹ã¯ãã¡ãã§ãï¼ https://github.com/akarinS/tipkotone/blob/master/README.md'139 return get_message(text, screen_name) if from_tweet else get_message(text)140 if command['method'] == 'follow':141 twitter.follow(user_id)142 text = 'ãã©ãã¼ãã¾ããï¼'143 return get_message(text, screen_name) if from_tweet else get_message(text)144 return None145def main(data: Dict) -> None:146 if 'tweet_create_events' in data:147 for event in data['tweet_create_events']:148 text = event['text']149 user_id = event['user']['id_str']150 screen_name = event['user']['screen_name']151 name = event['user']['name']152 status_id = event['id_str']153 if screen_name == BOTSCREENNAME:154 continue155 if re.match('(^RT |^QT |.* RT |.* QT ).*', text):156 continue157 message = execute(text, user_id, screen_name, name, True)...
messages.py
Source:messages.py
...4Client = client()5def Messages(user: int):6 language = Client.get_user_language(int(user))7 MESSAGES = {8 'start_message': Client.get_message(1, language),9 'ask_for_language': Client.get_message(2, language),10 'main_menu': Client.get_message(3, language),11 'category': Client.get_message(4, language),12 'product': Client.get_message(5, language),13 'quantity': Client.get_message(6, language),14 'cart_added': Client.get_message(7, language),15 'position_text': Client.get_message(8, language),16 'cart_header': Client.get_message(9, language),17 'cart_is_empty': Client.get_message(10, language),18 'cart_footer': Client.get_message(11, language),19 'edit_menu': Client.get_message(12, language),20 'cart_cleared': Client.get_message(13, language),21 'cart_restored': Client.get_message(14, language),22 'add_phone': Client.get_message(15, language),23 'phone_set': Client.get_message(16, language),24 'phone_length': Client.get_message(17, language),25 'phone_only_digits': Client.get_message(18, language),26 'delivery': Client.get_message(19, language),27 'real_name_get': Client.get_message(20, language),28 'location': Client.get_message(21, language),29 'time_set_delivery': Client.get_message(22, language),30 'time_set_self': Client.get_message(23, language),31 'set_time': Client.get_message(24, language),32 'time_set_success': Client.get_message(25, language),33 'payment_type': Client.get_message(26, language),34 'order_accepted': Client.get_message(27, language),35 'product_removed': Client.get_message(28, language),36 'paysystem_choose': Client.get_message(29, language),37 'order_header': Client.get_message(30, language),38 'order_cash': Client.get_message(31, language),39 'order_close_time': Client.get_message(32, language),40 'order_yes': Client.get_message(33, language),41 'order_no': Client.get_message(34, language),42 'order_edit': Client.get_message(35, language),43 'info_updated': Client.get_message(36, language),44 'checkout_title': Client.get_message(37, language),45 'checkout_description': Client.get_message(38, language),46 'set_branch': Client.get_message(39, language),47 'in_porgress_cooking': Client.get_message(40, language),48 'in_porgress_to_delivery': Client.get_message(41, language),49 'in_porgress_to_self': Client.get_message(42, language),50 'noNews': Client.get_message(43, language),51 'choose_events': Client.get_message(44, language),52 'noEvents': Client.get_message(45, language),53 'order_accepted_not_time': Client.get_message(46, language),54 }55 return MESSAGES56def GenerateCart(user: int):57 cart = Client.get_cart(user)58 language = Client.get_user_language(user)59 if cart is None:60 return [Messages(user)['cart_is_empty'], False]61 62 positions = cart.positions.all()63 for position in positions:64 if position.product.language.title != language:65 position.product = core_models.Product.objects.filter(66 language__title=language67 ).get(...
run_dialog_language.py
Source:run_dialog_language.py
...16 self.setupUi(self)17 self.set_resource()18 19 def set_resource(self):20 self.setWindowTitle(get_message("title"))21 self.tabWidget.setTabText(0, get_message("rack_tab_title"))22 self.tabWidget.setTabText(1, get_message("blade_tab_title"))23 self.connInfoBox.setTitle(get_message("conn_info"))24 self.ipLabel.setText(get_message("ip"))25 self.idLabel.setText(get_message("id"))26 self.pwLabel.setText(get_message("pw"))27 self.portLabel.setText(get_message("port"))28 self.addButton.setText(get_message("add"))29 self.removeButton.setText(get_message("delete"))30 self.connButton.setText(get_message("vkvm_conn"))31 self.bladeBox.setTitle(get_message("selected_blade"))32 self.statusBox.setTitle(get_message("status"))33 self.statusList.item(0).setText(get_message("status"))34 self.statusList.item(1).setText(get_message("status_ready"))35 self.statusList.item(2).setText(get_message("status_attached"))36 self.statusList.item(3).setText(get_message("status_etc"))37 self.statusList.item(3).setText(get_message("status_empty"))38 39if __name__ == "__main__":40 app = QApplication(sys.argv)41 dlg = XDialog()42 dlg.show()...
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!!