python-telegram-bot

Python Telegram Bot - run_daily does not work

£可爱£侵袭症+ 提交于 2020-06-27 16:18:41
问题 I have the same problem as in this thread run_daily doesn't do its job. run_once and run_repeating work well. I do not understand why. I tested your code but task is not carried out import telegram.ext from telegram.ext import Updater import datetime updater = Updater('My Token', use_context=True) job = updater.job_queue def callback_minute(context: telegram.ext.CallbackContext): context.bot.send_message(chat_id='My Chat ID', text='One message every minute') t = datetime.time(20, 2, 00,

Python Telegram Bot - run_daily does not work

你离开我真会死。 提交于 2020-06-27 16:18:32
问题 I have the same problem as in this thread run_daily doesn't do its job. run_once and run_repeating work well. I do not understand why. I tested your code but task is not carried out import telegram.ext from telegram.ext import Updater import datetime updater = Updater('My Token', use_context=True) job = updater.job_queue def callback_minute(context: telegram.ext.CallbackContext): context.bot.send_message(chat_id='My Chat ID', text='One message every minute') t = datetime.time(20, 2, 00,

how insert data in the sqlite3 tables while checking if exist using python

*爱你&永不变心* 提交于 2020-06-17 11:28:25
问题 i am trying to store the urerID and the urls they received, so i made a connector table Receive to save the ids of user and url. There are 2 problems here:- First problem : The ids are not incremented not by 1 but by the number the code is executed multiplied by the number of urls sent, here this happen after user1 used the code twice : user1 typed in telegram chat memes twice and received 2 memes + 2 memes. then user2 used the bot. Second problem : How to check in Receive table for the

How to send photo via Telegram Bot with file path?

穿精又带淫゛_ 提交于 2020-06-17 09:43:29
问题 I am trying to send a photo through my Telegram bot, but am getting an error. I have the file path of the photo on my computer. Maybe I am not putting the file path in correctly. The error I get is: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape`. Which is referring to right before the path name. This is the code I have: import requests import json bot_token = 'XXXXXX' chat_id = "-100YYYYYY" file = "C:\Users\name\OneDrive

Telegram bot API is the chat_id unique for each user contacting the bot?

回眸只為那壹抹淺笑 提交于 2020-05-29 07:43:52
问题 We are using python API for telegram bots and need to be able to identify the user. Is the chat_id unique for each user connecting the bot? Can we trust the chat_id to be consistent? e.g same chat_id will tell us that this is the same user, and each user connecting with the bot will have one chat_id that is consistent between sessions? Thanks 回答1: Is the chat_id unique for each user connecting the bot? Yes chat_id will always be unique for each user connecting to your bot. If the same user

How to deactivate inline mode in your Bot?

天大地大妈咪最大 提交于 2020-05-16 20:34:21
问题 How to deactivate inline mode in your Bot? When you talk to BotFather by /help he doesn't give any instructions. Thanks 回答1: Type /setinline , choose bot to disable inline mode, that type /empty . This will disable inline mode in your bot. 回答2: Use /setinline and then /setnoinline command to disable inline mode. 来源: https://stackoverflow.com/questions/37099589/how-to-deactivate-inline-mode-in-your-bot

Save telegram bot logs in a text file

大城市里の小女人 提交于 2020-03-05 03:16:11
问题 A telegram bot I created in python uses pyTelegramBotAPI API. To review logs, I was advised to use this line: logger = telebot.logger Now I can see my logs only in the terminal I'm running the bot with and when I close this terminal, the log data is lost. How can I save this logs to a text file? 回答1: From what I read in documentation here, it should be possible to use Python's handler to logger. Have you tried something like this import logging logger = telebot.logger telebot.logger

Remove telegram profile photo by telethon library or any API

有些话、适合烂在心里 提交于 2020-01-25 06:53:48
问题 I can't delete profile photo by telethon library or any else API What I already did below (using telethon) but it doesn't work from telethon import TelegramClient, sync from telethon.tl.functions.photos import DeletePhotosRequest api_id = "id" api_hash = "hash" client = TelegramClient("bot_5", api_id, api_hash) client.start() client(DeletePhotosRequest(client.get_profile_photos('me'))) I expected what this code would delete my profile photo How can I delete it with API? 回答1: this will work

How to write dynamic keyboard with conversationhandler in python telegram bot?

不打扰是莪最后的温柔 提交于 2020-01-16 11:59:44
问题 I am trying to write dynamic keyboard (buttons from a table in database ) But I am unable to get response in callbackqueryhandler in conversation handler. I am unable to go to next state which is response stored from a database column, My code : def menu(update,context): bot = context.bot name = db_execute("SELECT event_name FROM menu ", fetchall=True) button_list = [] for each in name: button_list.append(InlineKeyboardButton(each, callback_data = each)) reply_markup = InlineKeyboardMarkup

how save photo in telegram python bot?

女生的网名这么多〃 提交于 2020-01-10 20:11:10
问题 i want to write a telegram bot that save photos . this is my code , but its not working. and i don't know what is my problem? def image_handler(bot, update): file = bot.getFile(update.message.photo.file_id) print ("file_id: " + str(update.message.photo.file_id)) file.download('image.jpg') updater.dispatcher.add_handler(MessageHandler(Filters.photo, image_handler)) updater.start_polling() updater.idle() pleas help me to solve my problem. 回答1: update.message.photo is an array of photos sizes