Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
|
|
1 |
from telegram import Update
|
2 |
from telegram.ext import Application, CommandHandler, CallbackContext
|
|
|
3 |
|
4 |
# Function to start the bot and reply with a welcome message
|
5 |
async def start(update: Update, context: CallbackContext) -> None:
|
@@ -10,19 +12,25 @@ async def help_command(update: Update, context: CallbackContext) -> None:
|
|
10 |
await update.message.reply_text('Use /start to get started with the bot.')
|
11 |
|
12 |
# Main function to set up the bot
|
13 |
-
def
|
14 |
-
# Your bot token (replace with your actual bot token)
|
15 |
token = '7714605375:AAEfd-D1Y1np-HBJ0jOR1vGfyNJD2hloPAc'
|
16 |
-
|
17 |
-
# Create the Application and pass it your bot's token
|
18 |
application = Application.builder().token(token).build()
|
19 |
-
|
20 |
-
# Register handlers for commands
|
21 |
application.add_handler(CommandHandler("start", start))
|
22 |
application.add_handler(CommandHandler("help", help_command))
|
23 |
-
|
24 |
-
# Start the Bot
|
25 |
application.run_polling()
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
main()
|
|
|
1 |
+
import threading
|
2 |
from telegram import Update
|
3 |
from telegram.ext import Application, CommandHandler, CallbackContext
|
4 |
+
import time
|
5 |
|
6 |
# Function to start the bot and reply with a welcome message
|
7 |
async def start(update: Update, context: CallbackContext) -> None:
|
|
|
12 |
await update.message.reply_text('Use /start to get started with the bot.')
|
13 |
|
14 |
# Main function to set up the bot
|
15 |
+
def run_bot():
|
|
|
16 |
token = '7714605375:AAEfd-D1Y1np-HBJ0jOR1vGfyNJD2hloPAc'
|
|
|
|
|
17 |
application = Application.builder().token(token).build()
|
18 |
+
|
|
|
19 |
application.add_handler(CommandHandler("start", start))
|
20 |
application.add_handler(CommandHandler("help", help_command))
|
21 |
+
|
|
|
22 |
application.run_polling()
|
23 |
|
24 |
+
def main():
|
25 |
+
# Start the bot in a separate thread
|
26 |
+
bot_thread = threading.Thread(target=run_bot)
|
27 |
+
bot_thread.start()
|
28 |
+
|
29 |
+
# Now, you can start your web server or any other service that should run concurrently
|
30 |
+
# Example: Running a basic server or any other task.
|
31 |
+
print("Server is running...")
|
32 |
+
while True:
|
33 |
+
time.sleep(1) # Replace with actual server logic (e.g., web server loop)
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
main()
|