def planet(update, context): get_or_create_user(db, update.effective_user, update.message.chat.id) print(context.args) logging.info(context.args) if context.args[0].lower() == 'марс': logging.info('вызвана команда /planet Марс') now = datetime.datetime.now() mars = ephem.Mars(now) stars = ephem.constellation(mars) star_planet = (f'Сегодняшняя дата {now.strftime("%d-%m-%Y %H:%M")}.\n' f'Планета Марс находится в созвездии {stars[1]}') update.message.reply_text(star_planet, reply_markup=main_keyboard()) elif context.args[0].lower() == 'юпитер': logging.info('вызвана команда /planet Юпитер') now = datetime.datetime.now() jupiter = ephem.Jupiter(now) stars = ephem.constellation(jupiter) star_planet = (f'Сегодняшняя дата {now.strftime("%d-%m-%Y %H:%M")}.\n' f'Планета Юпитер находится в созвездии {stars[1]}') update.message.reply_text(star_planet, reply_markup=main_keyboard()) elif context.args[0].lower() == 'венера': logging.info('вызвана команда /planet Венера') now = datetime.datetime.now() venus = ephem.Venus(now) stars = ephem.constellation(venus) star_planet = (f'Сегодняшняя дата {now.strftime("%d-%m-%Y %H:%M")}.\n' f'Планета Венера находится в созвездии {stars[1]}') update.message.reply_text(star_planet, reply_markup=main_keyboard()) else: logging.info('вызвана команда неизвестная планета') update.message.reply_text('Такой планеты нет в моём списке!', reply_markup=main_keyboard())
def talk_to_me(update, context): user = get_or_create_user(db, update.effective_user, update.message.chat_id) text = update.message.text print(text) update.message.reply_text(f'{text} {user["emoji"]}', reply_markup=main_keyboard())
def anketa_comment(update, context): context.user_data['anketa']['comment'] = update.message.text user_text = anketa_format(context.user_data['anketa']) update.message.reply_text(user_text, reply_markup=main_keyboard(), parse_mode=ParseMode.HTML) return ConversationHandler.END
def greet_user(update: Update, context: CallbackContext) -> None: smile = get_smile() user_name = update.effective_user.first_name update.message.reply_text( f'Привет, {user_name}! Я самый лучший бот на свете {smile}', reply_markup=main_keyboard()) help(update, context)
def user_coordinates(update, context): context.user_data['emoji'] = get_smile(context.user_data) username = update.message.chat.username coord = update.message.location update.message.reply_text( f'{username}{context.user_data["emoji"]}! Твои координаты {coord}', reply_markup=main_keyboard())
def greet_user(update, context): print("Вызван /start") context.user_data['emoji'] = get_smile(context.user_data) update.message.reply_text( f"Здравствуй, пользователь {context.user_data['emoji']}!", reply_markup=main_keyboard() )
def talk_to_me(update, context): context.user_data['emoji'] = get_smile(context.user_data) username = update.effective_user.first_name text = update.message.text print(text) update.message.reply_text(f"{text} {context.user_data['emoji']}", reply_markup=main_keyboard())
def user_coordinates(update, context): user = get_or_create_user(db, update.effective_user, update.message.chat.id) coords = update.message.location update.message.reply_text( f"Ваши координаты {coords} {user['emoji']}!", reply_markup=main_keyboard() )
def greet_user(update, context): user = get_or_create_user(db, update.effective_user, update.message.chat.id) print("Вызван /start") update.message.reply_text( f"Здравствуй, пользователь {user['emoji']}!", reply_markup=main_keyboard() )
def greet_user(update, context): print("Вызван /start") user = get_or_create_user(db, update.effective_user, update.message.chat.id) #context.user_data['emoji'] = get_smile(context.user_data) update.message.reply_text(f"Привет, пользователь {user['emoji']}", reply_markup=main_keyboard())
def greet_user(update, context): """Greet func for /start message.""" context.user_data['emoji'] = get_smile(context.user_data) update.message.reply_text( 'Hello! {0}'.format(context.user_data['emoji']), reply_markup=main_keyboard(), )
def user_coordinates(update, context): context.user_data['emoji'] = get_smile(context.user_data) coords = update.message.location update.message.reply_text( f"Ваши координаты {coords} {context.user_data['emoji']}!", reply_markup=main_keyboard() )
def user_settings_set_asset(update, context): user_text = update.message.text if user_text == 'Валюта': keyboard = [[ InlineKeyboardButton("USD", callback_data='USD'), InlineKeyboardButton("EUR", callback_data='EUR') ], [ InlineKeyboardButton("JPY", callback_data='JPY'), InlineKeyboardButton("GBP", callback_data='GBP') ], [ InlineKeyboardButton("CNY", callback_data='CNY'), InlineKeyboardButton("Закончить", callback_data='Закончить') ]] currency_keyboard = InlineKeyboardMarkup(keyboard) update.message.reply_text('Выберете валюту или нажмите закончить', reply_markup=currency_keyboard) context.user_data['currency'] = [] user_text = update.message.text return 'currency' elif user_text == 'Акции': update.message.reply_text('Вы выбрали акции') elif user_text == 'Выйти': update.message.reply_text("Настройка завершена", reply_markup=main_keyboard()) return ConversationHandler.END
def send_cat_picture(update, context): cat_photos_list = glob('img/cat*.jp*g') cat_photo_filename = choice(cat_photos_list) chat_id = update.effective_chat.id context.bot.send_photo(chat_id=chat_id, photo=open(cat_photo_filename, 'rb'), reply_markup=main_keyboard())
def talk_to_me(update, context): user = get_or_create_user(db, update.effective_user, update.message.chat.id) #context.user_data['emoji'] = get_smile(context.user_data) text = update.message.text print(text) update.message.reply_text(f"{text} {user['emoji']}", reply_markup=main_keyboard())
def user_coordinates(update, context): context.user_data['emoji'] = get_smile(context.user_data) coordinates = update.message.location update.message.reply_text('Your coordinates {0} {1}'.format( coordinates, context.user_data['emoji'], ), reply_markup=main_keyboard())
def greet_user(update, context): print('Вызван/Start') username = update.effective_user.first_name context.user_data['emoji'] = get_smile(context.user_data) update.message.reply_text( f'Привет, {username}! {context.user_data["emoji"]}', reply_markup=main_keyboard() )
def greet_user(update, context): print("Вызыван /start") context.user_data['emoji'] = get_smile(context.user_data) # my_keyboard = ReplyKeyboardMarkup([['Очень нужен котик']]) update.message.reply_text( f"Ну здорова, отец {context.user_data['emoji']}!", reply_markup=main_keyboard() )
def send_cat_picture(update, context): """Choose random image from list.""" cat_images_list = glob('images/cat*.jp*g') random_cat_image = choice(cat_images_list) context.bot.send_photo( chat_id=update.effective_chat.id, photo=open(random_cat_image, 'rb'), reply_markup=main_keyboard(), )
def send_hero_picture(update, context): hero_list = glob("images/*png") hero_pic_filename = choice(hero_list) name_hero = hero_pic_filename.split('/')[1].split('.') chat_id = update.effective_chat.id context.bot.send_photo(chat_id=chat_id, photo=open(hero_pic_filename, 'rb'), reply_markup=main_keyboard()) update.message.reply_text(f"Твой герой {name_hero[0]}")
def anketa_profession(update, context): user_profession = update.message.text context.user_data["anketa"]["profession"] = user_profession user = get_or_create_user(db, update.effective_user, update.message.chat.id) save_anketa(db, user['user_id'], context.user_data['anketa']) update.message.reply_text("Отлично давай приступим к работе ", reply_markup=main_keyboard()) return ConversationHandler.END
def questionnaire_skip(update, context): user = create_or_get_user(db, update.effective_user, update.message.chat_id) save_questionnaire(db, user['user_id'], context.user_data['questionnaire']) user_text = format_questionnaire(context.user_data['questionnaire']) update.message.reply_text(user_text, reply_markup=main_keyboard(), parse_mode=ParseMode.HTML) return ConversationHandler.END
def get_stats(update, context): """ get stats """ results = defects_stat(DB) total = cars_stat(DB) text = f"""изображений с асфальтом: {results[0]} изображений с дефектом: {results[1]} изображений с посторонним предметом: {results[2]} всего машин: {total}""" update.message.reply_text(text, reply_markup=main_keyboard())
def anketa_skip(update, context): user_text = format_anketa(context.user_data['anketa']) user = get_or_create_user(db, update.effective_user, update.message.chat.id) save_anketa(db, user['user_id'], context.user_data['anketa']) update.message.reply_text(user_text, reply_markup=main_keyboard(), parse_mode=ParseMode.HTML) return ConversationHandler.END
def send_cat_picture(update, context): cat_photos_list = glob('images/cat*.jp*g') cat_pic_filename = choice(cat_photos_list) # указываем в явном виде в какой чат отправляем фото chat_id = update.effective_chat.id context.bot.send_photo(chat_id=chat_id, photo=open(cat_pic_filename, 'rb'), reply_markup=main_keyboard())
def send_cat_picture(update, context): user = get_or_create_user(db, update.effective_user, update.message.chat.id) cat_photo_list = glob('images/cat*.jp*g') cat_photo_filename = choice(cat_photo_list) chat_id = update.effective_chat.id context.bot.send_photo(chat_id=chat_id, photo=open(cat_photo_filename, 'rb'), reply_markup=main_keyboard())
def send_picture(update, context): user = get_or_create_user(db, update.effective_user, update.message.chat.id) cat_photos_list = glob('images/*.jp*g') cat_pic_filename = choice(cat_photos_list) chat_id = update.effective_chat.id context.bot.send_photo(chat_id=chat_id, photo=open(cat_pic_filename, 'rb')) update.message.reply_text("Привет, пользователь! Ты вызвал команду /start", reply_markup=main_keyboard())
def club(update, context): print('Вазван/Club') user_say = update.message.text.lower() if 'mutabor' in user_say: concert = concert_info(domain='mutabor.moscow') if 'random' in user_say: concert = concert_info(domain='rndm.club') update.message.reply_text(concert, reply_markup=main_keyboard())
def guess_number(update, context): if context.args: try: user_number = int(context.args[0]) message = play_random_numbers(user_number) except (TypeError, ValueError): message = 'Enter the integer number' else: message = 'What number?' update.message.reply_text(message, reply_markup=main_keyboard())
def guess_number(update, context): if context.args: try: user_number = int(context.args[0]) message = play_random_numbers(user_number) except (TypeError, ValueError): message = 'Введите целое число' else: message = 'Играем: введите число' return update.message.reply_text(message, reply_markup=main_keyboard())