Skip to content

Latest commit

 

History

History
118 lines (102 loc) · 3.59 KB

README.md

File metadata and controls

118 lines (102 loc) · 3.59 KB

Termbot

A fully fledged terminal emulator in a Discord chat, inspired by BashBot

Stars Open issues go version license

⚡️ Quick start

First, download and install Go. Version 1.18 or later is required.

Now you can clone the repo, and run the project.

git clone https://github.com/polyzium/termbot
cd termbot
go run .

Be sure to configure your instance before running the bot!

Features

  • Session management
  • Interactive mode
  • Autosubmit mode
  • Execution of a single command
  • Macros
  • TUI friendly
  • Color!

Color is experimental! As it uses ANSI escape codes the bot can easily reach Discord's 2000 character limit.

Usage

User settings are managed via slash commands. Terminal input is being done via the prefix (unless interactive mode is enabled).
The bot accepts shortcut sequences for keys. See the list below.

Shortcuts

Input Key name
\n Linefeed
\r Carriage Return (Enter)
\b Backspace
\t Tab
[ESC] Escape
[F1] F1
[F2] F2
[F3] F3
[F4] F4
[F5] F5
[F6] F6
[F7] F7
[F8] F8
[F9] F9
[F10] F10
[F11] F11
[F12] F12
[UP] Up Arrow
[DOWN] Down Arrow
[RIGHT] Right Arrow
[LEFT] Left Arrow
[INS] Insert
[DEL] Delete
[PGUP] Page Up
[PGDN] Page Down
^[key] Ctrl + key (i.e. ^C = Ctrl+C, etc)

Alt Key Combinations

In addition to the regular key inputs, you can also use Alt key combinations. Alt keys are represented by the escape character \x1b followed by your desired key. To find the codes for your Alt key combinations, you can use the showkey -a command in your terminal.
For example, if you press Alt-T or Alt-A, you'll get the following codes:

Press any keys - Ctrl-D will terminate this program

^[t      27 0033 0x1b
        116 0164 0x74
^[a      27 0033 0x1b
         97 0141 0x61

The ^[ represents the ESC key, or the escape character (\x1b). As you can see, it is followed by your desired key. To input Alt key combinations, simply type [ESC]<your character>, replacing <your character> with the key you want to emulate the Alt keypress with.
For example, to input Alt-T, you need to type [ESC]t.

Configuration

The configuration values are located in the config.yaml file. The keys should be pretty self explanatory.

Example:

token: YOUR_TOKEN_HERE
prefix: $
ownerid: "YOUR_USERID_HERE"
macros:
    - name: example
      in: Here's an example macro.
      whitelist: false
      allowedids: []
userprefs:
    "552930095141224479":
        defaultsharedusers:
            - "216836179415269376"
        color: false
        interactive: true
        autosubmit: true

Made with <3 using

DiscordGo
pty for Go
vt10x

Thanks to,

anic17 for testing
ZackeryRSmith for suggestions, and README

(Termbot is protected by the GPLv3 licence)