Skip to content

Instantly share code, notes, and snippets.

@YannickSF
Created January 16, 2023 23:24
Show Gist options
  • Save YannickSF/9d3f4da2bf20c6f1f15d827e9ff59868 to your computer and use it in GitHub Desktop.
Save YannickSF/9d3f4da2bf20c6f1f15d827e9ff59868 to your computer and use it in GitHub Desktop.

Quick Start :

Install dependances :

pip3 install -r requirements.txt

before launching script :

open script in editor there multiples variables in the top of the script.

  • ARGS, determine if the script launch by input parameters or with the assign one in the script.
  • BOT_KEY, "private_key" of the bot.
  • ADMIN, admin key.
  • BOT_NAME, ypu're bot name.

Start the script :

python3 stories_watcher.py <"login"> <"password"> <bot_sleep>

to stop program : ctrl + x

from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
class _Settings:
BOT_KEY = ''
ADMIN_ID = 0
BOT_NAME = ''
SETTINGS = _Settings()
def start(update, context):
"""Send a message when the command /start is issued."""
update.message.reply_text("Je suis {0}.".format(SETTINGS.BOT_NAME))
def answer(update, context):
update.message.reply_text(update.message.text)
def main():
"""Start the bot."""
updater = Updater(SETTINGS.BOT_KEY, use_context=True)
# Get JobQueue to schedule watch()
jb = updater.job_queue
# Get the dispatcher to register handlers
dp = updater.dispatcher
# on different commands - answer in Telegram
dp.add_handler(MessageHandler(Filters.text, answer))
dp.add_handler(CommandHandler("start", start))
# log all errors
# dp.add_error_handler(error)
# Start the Bot
updater.start_polling()
# Run the bot until you press 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()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment