Exemplo n.º 1
0
def send_broadcast_all(bot, update):
    bot.sendChatAction(chat_id=update.message.chat.id, action=telegram.ChatAction.TYPING)

    if utils.is_private(update.message) and security.is_authorized(update.message, 'admin'):
        conn = sqlite3.connect(configuration.db_users_path)
        c = conn.cursor()
        c.execute("SELECT chat_id FROM USERS WHERE chat_allowed = 1")
        rows = c.fetchall()
        for row in rows:
            if row[0] != str(update.message.chat.id):
                bot.sendMessage(chat_id=row[0], text=command_payload(update.message.text))
        conn.close()
        bot.sendMessage(chat_id=update.message.chat_id, text='Message successfully broadcasted to known users.')
Exemplo n.º 2
0
def change_users_flags(bot, update):
    bot.sendChatAction(chat_id=update.message.chat.id, action=telegram.ChatAction.TYPING)

    if utils.is_private(update.message) and security.is_authorized(update.message, 'admin'):
        tokens = update.message.text.split(' ')

        if( len(tokens) == 1):
            command_info(bot,update)
        elif( len(tokens) == 2 and tokens[1] == 'list'):
            show_users(bot,update)
        elif( len(tokens) > 2 ):
            command = tokens[0]
            userId = tokens[1]
            flagMask = tokens[2]
            update_flags(bot,update,userId,flagMask)
        else:
            command_info(bot,update)
Exemplo n.º 3
0
def set_admin_mediation(bot, update):
    if security.is_authorized(update.message, 'admin'):
        global admin_mediation
        admin_mediation = not admin_mediation
        bot.sendMessage(chat_id=update.message.chat_id, text='Admin mediation set to ' + str(admin_mediation))
Exemplo n.º 4
0
def do_stop(bot, update):
    if security.is_authorized(update.message, 'admin'):
        updater.stop()
        sys.exit(0)
Exemplo n.º 5
0
def error_handler(bot, update, error):
    if is_authorized(update):
        err_msg = 'Update "{}" caused error "{}"'.format(update, error)
        send_message(bot, update, err_msg)
Exemplo n.º 6
0
def send_picture(bot, update):
    bot.sendChatAction(chat_id=update.message.chat.id, action=telegram.ChatAction.TYPING)
    if security.is_authorized(update.message, 'webcam_allowed'):
        if utils.is_private(update.message):
            bot.sendPhoto(chat_id=update.message.chat.id, photo=get_picture(update.message.chat.id))