コード例 #1
0
ファイル: daemon.py プロジェクト: xiaofd/coolq-telegram-bot
    def run(self):
        qq_bot = CQBot(CQ_PORT)
        tg_bot = None
        global_vars.set_qq_bot(qq_bot)
        global_vars.set_tg_bot_id(int(TOKEN.split(':')[0]))

        updater = Updater(TOKEN)
        job_queue = updater.job_queue
        tg_bot = updater.bot
        global_vars.set_tg_bot(tg_bot)
        # Get the dispatcher to register handlers
        dp = updater.dispatcher
        global_vars.set_dp(dp)
        dp.add_error_handler(error)
        dp.add_handler(CommandHandler('start', start), group=0)

        qq_bot.start(
        )  # start bot before add handler, in order to execute init correctly
        updater.start_polling(poll_interval=1.0, timeout=200)

        import plugins

        # Block until the you presses Ctrl-C or the process receives SIGINT,
        # SIGTERM or SIGABRT. This should be used most of the time, since
        # start_polling() is non-blocking and will stop the bot gracefully.
        updater.idle()
コード例 #2
0
ファイル: Instagram.py プロジェクト: dragon0629/InsMonitor
		pic = pic[count]["src"]
		comments = data[0]["node"]["edge_media_to_comment"]["count"]
		like = data[0]["node"]["edge_liked_by"]["count"]
		url = data[0]["node"]["shortcode"]
		url = 'https://www.instagram.com/p/' + url
	except Exception as e:
		insTime = 0
		text = ''
		like = 0
		comments =0
		pic = ''
		url = ''
	return int(insTime),str(text),int(like),int(comments),str(pic),str(url)

qqbot = CQBot(11235)
qqbot.start()
proxy = '127.0.0.1:8118'
proxies = {
    'http': 'http://' + proxy,
    'https': 'https://' + proxy
}
print('开始获取INS')
dataIns = getIns(urlINS)
Instext = dataIns[0]
Inspicurl = dataIns[1]
print(Inspicurl)
Insweburl = dataIns[2]
insTime = dataIns[0]
print('最新INS时间:' + str(insTime))

while True:
コード例 #3
0
ファイル: mybot.py プロジェクト: swd1119/coolq-telegram-bot
def set_drive_mode(forward_index, status, tg_group_id, qq_group_id):
    ## set drive mode on/off
    global tg_bot
    global qq_bot
    global drive_modes
    if status == 1:
        msg = 'Telegram向QQ转发消息已暂停'
    elif status == 0:
        msg = 'Telegram向QQ转发消息已重启'
    drive_modes[forward_index] = status
    tg_bot.sendMessage(tg_group_id, msg)
    qq_bot.send(SendGroupMessage(group=qq_group_id, text=msg))


def keep_main_thread():
    ## keep main thread running
    while True:
        time.sleep(10)


# main
if __name__ == '__main__':
    try:
        qq_bot.start()
        MessageLoop(tg_bot, tg_msg_receive).run_as_thread()
        print("Starting...")
        keep_main_thread()
    except KeyboardInterrupt:
        print("Stopping...")
コード例 #4
0
ファイル: twbot.py プロジェクト: yukixz/cqbot
            path=os.path.join(
                CQ_IMAGE_ROOT, Avatar.image_subdir, filename),
            requests_kwargs=REQUESTS_OPTIONS_PROXIED
        ).run()
        Avatar.latest = url

        text = '\n'.join([
            user['name'],
            "【アイコン変更】",
            str(CQImage(os.path.join(Avatar.image_subdir, filename)))
        ])
        for notify in NOTIFY:
            if '*Avatar' not in notify.get('type'):
                continue
            for g in notify['group']:
                qqbot.send(SendGroupMessage(group=g, text=text))


################
# __main__
################
if __name__ == '__main__':
    try:
        qqbot.start()
        scheduler.start()
        print("Running...")
        input()
        print("Stopping...")
    except KeyboardInterrupt:
        pass