示例#1
0
    except:
        zee5 = (open("hits\\zee5.txt", "w")).truncate(0)
        nord = (open("hits\\nordvpn.txt", "w")).truncate(0)
        voot = (open("hits\\voot.txt", "w")).truncate(0)
        ipvanish = (open("hits\\ipvanish.txt", "w")).truncate(0)
        uplay = (open("hits\\uplay.txt", "w")).truncate(0)
        altbalaji = (open("hits\\altbalaji.txt", "w")).truncate(0)
        hulu = (open("hits\\hulu.txt", "w")).truncate(0)
        wwe = (open("hits\\wwe.txt", "w")).truncate(0)
        crunchyroll = (open("hits\\crunchyroll.txt", "w")).truncate(0)


updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher

dispatcher.add_handler(CommandHandler("start", start), group=1)
dispatcher.add_handler(CommandHandler("accounts", accounts), group=1)
dispatcher.add_handler(CommandHandler("upload", upload,
                                      Filters.user(username=admins)),
                       group=1)
dispatcher.add_handler(CommandHandler("admin", admin,
                                      Filters.user(username=admins)),
                       group=1)
dispatcher.add_handler(CallbackQueryHandler(button_click), group=1)
dispatcher.add_handler(CommandHandler("clear", clear_db,
                                      Filters.user(username=admins)),
                       group=1)
dispatcher.add_handler(CommandHandler("rem_admin", rem_admin,
                                      Filters.user(username=admins)),
                       group=1)
dispatcher.add_handler(CommandHandler("add_admin", add_admin,
示例#2
0
def start(update, context):
    response = random.choice(
        greetings
    ) + '\nI will help you manage your spending and get whatever you send me into a spreadhseet.'
    context.bot.send_message(chat_id=update.effective_chat.id, text=response)
    print(bot_instances)


@run_async
def bot_handler(update, context):
    chat_id = update.effective_chat.id
    if chat_id not in bot_instances.keys():
        bot = BudgetBot(chat_id)
        bot_instances[chat_id] = bot
    else:
        bot = bot_instances[chat_id]

    message = bot.text_formatter(update.message.text)

    if bot.match_intent(message) == True:
        context.bot.send_message(chat_id=bot.chat_id,
                                 text='Successfully added to DB')


start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)

plain_text_handler = MessageHandler(Filters.text, bot_handler)
dispatcher.add_handler(plain_text_handler)

updater.start_polling()
def main():
    updater = Updater(TOKEN, use_context=True)
    dispatcher = updater.dispatcher
    updater.dispatcher.add_handler(CallbackQueryHandler(button))

    dispatcher.add_handler(CommandHandler("start", start))
    dispatcher.add_handler(CallbackQueryHandler(short_buttons))
    dispatcher.add_handler(CommandHandler("help", assist))
    dispatcher.add_handler(CommandHandler("short", short))
    dispatcher.add_handler(CommandHandler("unshort", unshort))
    dispatcher.add_handler(CommandHandler("screen", screen))
    dispatcher.add_handler(CommandHandler("about", aboutTheBot))
    dispatcher.add_handler(CommandHandler("donate", donate))
    dispatcher.add_error_handler(error)

    if WEBHOOK:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen="0.0.0.0", port=PORT, url_path=TOKEN)
        updater.bot.set_webhook(url=URL + TOKEN)

    else:
        LOGGER.info("Using long polling.")
        updater.start_polling(timeout=15, read_latency=4)

    updater.idle()
示例#4
0
updater = Updater(token="893162503:AAGwD5FvkRYYs297kEMkI_wvI0gdbaG6p7Y",
                  use_context=True)
dispatcher = updater.dispatcher
logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    level=logging.INFO)


# Envia uma resposta ao receber o comando /start
def start(update, context):
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text="Falaa jovem, qual a QTC?")


start_handler = CommandHandler("start", start)
dispatcher.add_handler(start_handler)


# Repete as mensagens digitadas no bot após o comando /start
def echo(update, context):
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text=update.message.text)


echo_handler = MessageHandler(Filters.text & (~Filters.command), echo)
dispatcher.add_handler(echo_handler)


# Formata as mensagens em caixa alta (CAPS-LOCK)
def caps(update, context):
    text_caps = " ".join(context.args).upper()
OWNER_ID = 461490935  # Owner
OWNER_USERNAME = "******"  # my username

updater = Updater(token=API)
dispatcher = updater.dispatcher


def help(bot, update):
    if update.effective_chat.type == "private":
        bot.send_message(chat_id=update.message.chat_id, text=help_message)
    else:
        update.effective_message.reply_text("Type that on pm please!")


help_handler = CommandHandler('help', help)
dispatcher.add_handler(help_handler)

id_handler = CommandHandler('id', modules.id.id)
dispatcher.add_handler(id_handler)

version_handler = CommandHandler('version', modules.version.version)
dispatcher.add_handler(version_handler)

leaveit_handler = CommandHandler('leaveit', modules.leavegroup.leavegroup)
dispatcher.add_handler(leaveit_handler)

unpin_handler = CommandHandler('unpin', modules.pin.unpin)
dispatcher.add_handler(unpin_handler)

warn_handler = CommandHandler('warn', modules.warns.warn)
dispatcher.add_handler(warn_handler)
示例#6
0
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text="I'm a bot, please talk to me!")


def hello(update, context):
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text='Que te pasa puta? queres que te la ponga?')


def russian_roulette(update, context):
    chat_id = update.effective_chat.id
    user_id = update.message.from_user.id
    user_id = random.choice([user_id, False, False, False, False, False])
    if user_id:
        try:
            context.bot.kick_chat_member(chat_id=chat_id, user_id=user_id)
        except BadRequest as error:
            context.bot.send_message(chat_id=chat_id, text=str(error.message))
    else:
        context.bot.send_message(chat_id=chat_id, text="Safaste Wachin")


dispatcher = updater.dispatcher

start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(CommandHandler('hello', hello))
dispatcher.add_handler(CommandHandler('russian_roulette', russian_roulette))

updater.start_polling()
updater.idle()