Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions telegram bot scheduler/README.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Telegram Bot Task Scheduler

This is a Telegram bot that allows you to schedule tasks with specific dates and times.

## Prerequisites

- Python 3.x
- `telebot` library
- `sched` module

## Getting Started

1. Clone the repository:


2. Install the required libraries:

Telebot,time,sched modules

3. Set up a Telegram bot and obtain the bot token. You can follow the official Telegram Bot documentation to create a new bot: [https://core.telegram.org/bots#creating-a-new-bot](https://core.telegram.org/bots#creating-a-new-bot)

4. Replace the placeholder token in the code:

```python
bot = telebot.TeleBot('YOUR_BOT_TOKEN')
5.Run the python bot.py

30 changes: 30 additions & 0 deletions telegram bot scheduler/Telegram.py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import telebot
import sched
import time

# Create a new bot instance
bot = telebot.TeleBot('6142986288:AAH4FgY0ZHx-r4qnWl3vO5JbCRvmrJ2T1W8')

# Handle the '/start' command
@bot.message_handler(commands=['start'])
def handle_start(message):
bot.reply_to(message, "enter as /set task name(withoutgap) YYYY-DD-MM HH:MM:SS")

# Modify this line if necessary

@bot.message_handler(commands=['set'])
def handle_message(message):
o=message.text.split('/set ')[1].split(' ',1)
j=o[1]
p=o[0]
s = sched.scheduler(time.time, time.sleep)
def your_function():
bot.reply_to(message,p)

s.enterabs(time.mktime(time.strptime(j, "%Y-%m-%d %H:%M:%S")), 1, your_function)
s.run()

# Start the bot
bot.polling()