def send_document(chat_id, data, **kwargs): """Send a document :arg chat_id :arg data :key reply_to_message_id :key caption :key parse_mode""" return BOT.send_document(chat_id, data, **kwargs)
def send_video(chat_id, video, **kwargs): """Send a video :arg chat_id :arg video :key caption :key reply_to_message_id :key reply_markup :key parse_mode""" return BOT.send_video(chat_id, video, **kwargs)
def send_photo(chat_id, photo, **kwargs): """Send a photo :arg chat_id :arg photo :key caption :key reply_to_message_id :key reply_markup :key parse_mode""" return BOT.send_photo(chat_id, photo, **kwargs)
def request_file(file_id, save_as): file_info = BOT.get_file(file_id) req = requests.get("https://api.telegram.org/file/bot{0}/{1}".format( BOT.token, file_info.file_path)) file_out = open("input+" + file_info.file_path, "w") lines = req.content() file_out.write(lines) req.close() file_out.close()
def restrict(chat_id, user_id, **kwargs): """Restrict a chat member :arg chat_id :arg user_id :key until_date :key can_send_messages :key can_send_media_messages :key can_send_other_messages :key can_add_web_page_previews""" return BOT.restrict_chat_member(chat_id, user_id, **kwargs)
def send(chat_id, message_text, **kwargs): """Send a message :arg chat_id :arg message_text :key parse_mode :key reply_markup""" return BOT.send_message(chat_id, message_text, disable_web_page_preview=True, **kwargs)
def reply(message, message_text, **kwargs): """Reply to a message :arg message: message bot replies to :arg message_text :key parse_mode :key reply_markup""" return BOT.reply_to(message, str(message_text), disable_web_page_preview=True, **kwargs)
def send_voice(chat_id, voice, **kwargs): """Send a voice :arg chat_id :arg voice :key caption :key duration :key parse_mode :key reply_to_message_id :key reply_markup :key disable_notification :key timeout""" return BOT.send_voice(chat_id, voice, **kwargs)
def edit_text(text, chat_id, message_id, **kwargs): """Edit the text of a message :arg text :arg chat_id :arg message_id :key parse_mode :key reply_markup""" return BOT.edit_message_text(text, chat_id, message_id, disable_web_page_preview=True, **kwargs)
def promote(chat_id, user_id, **kwargs): """Change admin permissions of a person :arg chat_id :arg user_id :key can_change_info :key can_post_messages :key can_edit_messages :key can_delete_messages :key can_invite_users :key can_restrict_members :key can_pin_messages :key can_promote_members""" LOG.log(f"promote invoked chat_id={chat_id}, user_id={user_id}") return BOT.promote_chat_member(chat_id, user_id, **kwargs)
# -*- coding: utf-8 -*- """Main program in the code. Run it""" # from requests import ReadTimeout, ConnectionError # from urllib3.exceptions import NewConnectionError, MaxRetryError, ReadTimeoutError import view.input from presenter.config.token_manager import BOT, BOT_CONFIGS from presenter.config.config_var import CREATOR_ID from presenter.config.config_func import update_old_systems_json print(view.input.WORK) update_old_systems_json() if BOT_CONFIGS['non_stop']: BOT.send_message(CREATOR_ID, "Приступаю к работе в бесконечном режиме, босс!") BOT.infinity_polling() # Запуск бота else: # telebot.logger.setLevel("DEBUG") # Иногда помогает, но обычно не нужна BOT.send_message(CREATOR_ID, "Приступаю к работе, босс!") BOT.polling(none_stop=True)
def delete(chat_id, message_id): """Delete a message""" return BOT.delete_message(chat_id, message_id)
def edit_markup(chat_id, message_id, reply_markup=None): """Edit buttons of the message""" return BOT.edit_message_reply_markup(chat_id, message_id, reply_markup=reply_markup)
def get_chat(chat_id): """Get a chat""" return BOT.get_chat(chat_id)
def get_me(): """ Get information about bot """ return BOT.get_me()
def get_member(chat_id, user_id): """Get a member of a chat""" return BOT.get_chat_member(chat_id, user_id)
def register_handler(sent, function, *args, **kwargs): """Next message will be processed with specified function""" return BOT.register_next_step_handler(sent, function, *args, **kwargs)
def kick(chat_id, user_id): """Kick a user""" return BOT.kick_chat_member(chat_id, user_id)
def unban(chat_id, user_id): """Unban member""" return BOT.unban_chat_member(chat_id, user_id)
def send_sticker(chat_id, sticker, reply_to_message_id=None): """Send a sticker""" return BOT.send_sticker(chat_id, sticker, reply_to_message_id=reply_to_message_id)
def answer_inline(inline_query_id, results, cache_time=None): """Show a result of an inline-request""" return BOT.answer_inline_query(inline_query_id, results, cache_time=cache_time)
def answer_callback(callback_query_id, text=None, show_alert=False): """Show a notification on a top of a messsage box (or a alert)""" return BOT.answer_callback_query(callback_query_id, text, show_alert)
def forward(chat_id, from_chat_id, message_id): """Forward a message""" return BOT.forward_message(chat_id, from_chat_id, message_id)
def get_file(file_id: int): """Get basic infor about a file and prepare it for downloading :arg file_id: id of the file""" return BOT.get_file(file_id)