예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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()
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
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)
예제 #8
0
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)
예제 #9
0
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)
예제 #10
0
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)
예제 #11
0
# -*- 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)
예제 #12
0
def delete(chat_id, message_id):
    """Delete a message"""
    return BOT.delete_message(chat_id, message_id)
예제 #13
0
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)
예제 #14
0
def get_chat(chat_id):
    """Get a chat"""
    return BOT.get_chat(chat_id)
예제 #15
0
def get_me():
    """ Get information about bot """
    return BOT.get_me()
예제 #16
0
def get_member(chat_id, user_id):
    """Get a member of a chat"""
    return BOT.get_chat_member(chat_id, user_id)
예제 #17
0
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)
예제 #18
0
def kick(chat_id, user_id):
    """Kick a user"""
    return BOT.kick_chat_member(chat_id, user_id)
예제 #19
0
def unban(chat_id, user_id):
    """Unban member"""
    return BOT.unban_chat_member(chat_id, user_id)
예제 #20
0
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)
예제 #21
0
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)
예제 #22
0
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)
예제 #23
0
def forward(chat_id, from_chat_id, message_id):
    """Forward a message"""
    return BOT.forward_message(chat_id, from_chat_id, message_id)
예제 #24
0
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)