Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
import requests
|
3 |
+
from telegram import Update
|
4 |
+
from telegram.ext import Updater, CommandHandler, CallbackContext
|
5 |
+
|
6 |
+
# Set up logging
|
7 |
+
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
8 |
+
|
9 |
+
# Your SocPanel API key and endpoint
|
10 |
+
SOC_PANEL_API_KEY = 'yho1ES9sQ51udmTgAapCtRqJtM8zeiLKoLkHod1QWkR8bzSkttHb8yifFrNf'
|
11 |
+
SOC_PANEL_API_URL = 'https://socpanel.com/privateApi'
|
12 |
+
|
13 |
+
# Your Telegram bot token
|
14 |
+
TELEGRAM_BOT_TOKEN = '7684829859:AAHABWrxsMDF3L9Xo4A5xZBwtIu76dL19dY'
|
15 |
+
|
16 |
+
def start(update: Update, context: CallbackContext) -> None:
|
17 |
+
update.message.reply_text('Welcome to the Followers Bot! Use /add_follower to add a follower.')
|
18 |
+
|
19 |
+
def add_follower(update: Update, context: CallbackContext) -> None:
|
20 |
+
# Example of how to call the SocPanel API to add a follower
|
21 |
+
user_id = context.args[0] if context.args else None
|
22 |
+
if user_id:
|
23 |
+
response = requests.post(f"{SOC_PANEL_API_URL}/add_follower", data={
|
24 |
+
'api_key': SOC_PANEL_API_KEY,
|
25 |
+
'user_id': user_id
|
26 |
+
})
|
27 |
+
if response.status_code == 200:
|
28 |
+
update.message.reply_text(f"Follower {user_id} added successfully!")
|
29 |
+
else:
|
30 |
+
update.message.reply_text("Failed to add follower.")
|
31 |
+
else:
|
32 |
+
update.message.reply_text("Please provide a user ID.")
|
33 |
+
|
34 |
+
def main() -> None:
|
35 |
+
updater = Updater(TELEGRAM_BOT_TOKEN)
|
36 |
+
|
37 |
+
dispatcher = updater.dispatcher
|
38 |
+
dispatcher.add_handler(CommandHandler("start", start))
|
39 |
+
dispatcher.add_handler(CommandHandler("add_follower", add_follower))
|
40 |
+
|
41 |
+
updater.start_polling()
|
42 |
+
updater.idle()
|
43 |
+
|
44 |
+
if __name__ == '__main__':
|
45 |
+
main()
|