vicalloy / telegram-shell-bot

A telegram Bot to run shell commands
194 stars 83 forks source link

'oa;command' is not working as expected but '/script oa;script' is #14

Closed guerman5 closed 2 years ago

guerman5 commented 2 years ago

Hi dear @vicalloy and friends, thanks for the great tool

I've implemented TG-shell-bot in an old android6 with termux, its running awesome with pm2

The issue: following the instruction how to use oa; in the case oa;command "add oa in command to send all output. E.g.:" oa;ping google.com /script oa;demo.py

only /script oa;script is working image

I tried to change the CMD_BLACK_CHARS in settings file, thinking that ';' might be the culprit, but results were the same image

Hope its just a typo somewhere, easy fix.

Happy new year! Cheers Guer

vicalloy commented 2 years ago

I tested on web and ios client, oa;ping google.com is works ok.

guerman5 commented 2 years ago

Thanks for your time. I also used ios client to send the command (screenshots above), as well as windows client. Notice that my TGshellbot is running in Termux. what about your environment?

Im trying to find the logs, but all I can get is the feed when running bot.py (screenshot below) image Each entry you see above, only happens when I send a command without the oa; (successful btw)

bot.py:163: TelegramDeprecationWarning: The @run_async decorator is deprecated. Use the `run_async` parameter of your Handler or `Dispatcher.run_async` instead.
  __do_exec(cmd, update, context)

If I throw an oa;command nothing happens

vicalloy commented 2 years ago

You can add some debug code to see what happend. ex:

@restricted
def do_exec(update, context):
    print('enter do_exec with message: ', update.message)
    if not update.message:
        return
    if __do_cd(update, context):
        print('do cd and return')
        return
    cmd: str = update.message.text
    if not __check_cmd(cmd):
        print('cmd is not allowed:', cmd)
        return
    print('__do_exec')
    __do_exec(cmd, update, context)
guerman5 commented 2 years ago

I added the print lines , after running the different command syntaxes , no extra output on the chat window nor live log entries. Dont know what I'm doing wrong, I might be confused what I should expect to happen.

Later, I update the code, cloned the recent changed files. Same result, same issue on my side Then I fresh installed in another environment (Archlinux), runs exactly as it does in Termux.

The only settings i modify are the API_TOKEN, USERS and CMD_WHITE

TOKEN = os.environ.get("TELEGRAM_API_TOKEN", '123:sfdDKF_FKDjdf45')
ENABLED_USERS = os.environ.get("ENABLED_USERS", '11111')
CMD_WHITE_LIST = {'date', 'ping', 'ls'}

So, if is not the environment and the settings are ok, why is not working :S