tras

command module
v0.0.0-...-79c3f0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 21 Imported by: 0

README

Text Response Automation System

  _|_|_|_|_|  _|_|_|_|       _|       _|_|_|_|
 /////_|///  /_|////_|      _|_|     _|////// 
     /_|     /_|   /_|     _|//_|   /_|       
     /_|     /_|_|_|_|    _|  //_|  /_|_|_|_| 
     /_|     /_|///_|    _|_|_|_|_| ////////_|
     /_|     /_|  //_|  /_|//////_|        /_|
     /_|     /_|   //_| /_|     /_|  _|_|_|_| 
     //      //     //  //      //  ////////

Version 3.0.1

Made by Nathan Hedge @ https://almostd.one/


A Discord bot for text-based commands and responses.

This may sound like any other bot at first, but this is much more than basic text.




LIST OF COMMANDS

@TRAS help or /help

Summons a help list. Slash command doesn't require DMs

@TRAS about or /about

Gives information about the bot. Add "NoCB" for devices that don't support links with command blocks. Slash command doesn't require DMs

@TRAS oof

Mega OOF

@TRAS f

Mega F

@TRAS pi

First 1 million digits of Pi

@TRAS big

Make a larger verison of word/text made of the letter. Starts getting wonky with emojis. Becomes file over 400 characters. You can enable thin letters with -t or --thin.

Format: @TRAS big (-t/--thin) [letter] [text]

@TRAS jumble

Jumbles the words in a sentence so it's confusing to read.

Format: @TRAS jumble [text]

@TRAS emojify

Turn all characters into emojis.

Format: @TRAS emojify [text]

@TRAS flagify

Turn all letters into regional indicators, creating flags.

Format: @TRAS flagify [text]

@TRAS superscript

Turn all numbers and letters plus a few math symbols into superscript. Some letters are always lowercase or replaced with something similar due to Unicode limitations.

Format: @TRAS superscript [text]

@TRAS unicodify

Turn all numbers and letters into a non-Latin equivilant.

Format: @TRAS unicodify [text]

@TRAS bold

Bolds all Latin letters and numbers using Unicode.

Format: @TRAS bold [text]

@TRAS replace

Replaces every appearance of a set item with a set replacement.

Format: @TRAS replace [item] [replacement] [text]

@TRAS overcomplicate

Replaces all words with synonyms of the word.

Format: @TRAS overcomplicate [text]

@TRAS word info

Get the definition or Part-of-Speech of a word.

Format: @TRAS word info [definition/pos] [word]

@TRAS ascii art

Generate ascii art. Over 400 characters returns in a file.

Format: @TRAS ascii art [font/getFonts] [text]

@TRAS commands

View and manage custom server commands, managing requires administrator perms. Custom commands feature may require TRAS Deluxe in the future (TBD, currently not a thing). Schedule feature not currently implemented.

Format: @TRAS commands [manage/view] [(manage)...] Format (manage): @TRAS commands manage [set/delete/schedule] [(set/delete)trigger//(schedule)time of day (hh:mm:ss)] [(set/schedule)reply]

@TRAS rank

Shows your rank, lets your reset your rank, and allows you to roll dice for a new rank if it's enabled. Admins get other commands as well. Dice rolling disabled by default.

Format: @TRAS rank [info/checkDice/dice] [(info)-real] Format (admin): @TRAS rank [set/reset/toggleDice] [(set/reset)user] [value]

@TRAS set nickname

Set the bot's Nickname on the server. Reset with "{RESET}". Requires "Manage Messages" or "Change Nicknames".

Format: @TRAS set nickname [nickname/{RESET}] Reset alternative: @TRAS reset nickname

@TRAS speak

Generate a sentence, plus toggle and get the status of random generated messages. Toggling requires "Manage Messages" permissions. Random messages are off by default. Frequent generation may require TRAS Deluxe in the future (TBD, currently not a thing).

Format: @TRAS speak [generate/randomspeak] [(randomspeak)on/off/status]

@TRAS combinations

Sends file with all possible combinations of the units you have selected and given.

Format: @TRAS combinations [words/characters] [items]

@TRAS ping

Check if the bot is alive. Add 'info' or 'information' for latency data.

Default response

Responds "What's up?"

Generated messages

Fully generated messages (not an AI so they're completely nonsensical) can be toggled to randomly say them in response to user messages. Random messages will not reply to commands. Toggle random messages with @TRAS speak randomspeak [on/off]




GENERAL DETAILS

All data is stored in Postgres.

Large items are stored in files.

Controversial features are toggleable.

Custom commands are activated like normal commands. / Ex: @TRAS [trigger]

ALL commands (except for some modifiers) work with aNY CapItaLIzATIoN.

All commands should work in DMs.

Ranking levels are base 2 logarithms of your progress.

Spaces can be included in individual arguments by using escapes / Ex: This\ is\ one\ argument, but\ this\ is\ the\ second

Escaped slashes can still be used at the end of individual arguments / Ex: This\ is\ one\ argument\\ but\ this\\\ is\ the\ second




TRAS logo



Documentation

Overview

This is based on the speech generation of old TRAS, available at https://github.com/10Nates/tras-old/blob/main/speechgen.js. Note, I made tras-old before GPT2, and I was completely unaware of LLMS, so that was basically my uneducatedversion of it.

The basic idea is to algorithmically generate sentences in the same theme as Noam Chomsky's "Colorless green ideas sleep furiously." That is, a context-free grammar generator using transformational grammer. In the future, my plan is to give it meaning, or at least better structure, and perhaps even make my own neural network that isn't quite as heavy as the GPTs.

After a lot of back and forth with ChatGPT including a lot of acronyms for subjects that didn't exist, some code surgery, and a few original ideas, I made this "mockup" in JS (it's fully functional but JS is a toy language)

```js const WordPOS = require('wordpos'); const wordpos = new WordPOS();

// Function to get a random element from an array

function getRandomElement(array) {
    return array[Math.floor(Math.random() * array.length)];
}

// Function to get a random noun

async function randomNoun() {
    const nouns = await wordpos.randNoun();
    return getRandomElement(nouns);
}

// Function to get a random verb

async function randomVerb() {
    const verbs = await wordpos.randVerb();
    return getRandomElement(verbs);
}

// Function to get a random adverb

async function randomAdverb() {
    const adverbs = await wordpos.randAdverb();
    return getRandomElement(adverbs);
}

// Function to get a random adjective

async function randomAdjective() {
    const adjectives = await wordpos.randAdjective();
    return getRandomElement(adjectives);
}

const grammar = {
    S: ['NP VP'],
    NP: ['Det N', 'Det AP N', 'Det N PP'],
    VP: ['V', 'V NP', 'V NP PP', 'V Adv', 'V Adv NP'],
    PP: ['P NP'],
    AP: ['A', 'A AP'],
    Det: [...],
    N: [ randomNoun ],
    V: [ randomVerb ],
    P: [...],
    Adv: [ randomAdverb ],
    A: [ randomAdjective ],
};

// Function to expand a non-terminal symbol

async function expand(symbol) {
    if (grammar[symbol]) {
        const expansions = grammar[symbol];
        let chosenExpansion = expansions[Math.floor(Math.random() * expansions.length)];
        if (typeof chosenExpansion === "function") {
            chosenExpansion = await chosenExpansion();
        }
        const symbols = chosenExpansion.split(' ');
        let asyncJoin = "";
        for (let i = 0; i < symbols.length; i++) {
            asyncJoin += (i > 0 ? " " : "") + await expand(symbols[i])
        }
        return asyncJoin;
    }
    return symbol;
}

// Generate a sentence

async function generateSentence() {
    return await expand('S');
}

// Generate and log a sentence generateSentence().then(console.log) ```

I then moved to Bing Chat in order to get more detail on grammar types that were not yet included and I was not yet aware off, then I had it convert ITS Python into Go. This is is what I got from that:

```go // A context-free grammar generator using phase structure rules // The grammar can generate sentences with the following parts: // - Subject (S) // - Verb (V) // - Object (O) // - Complement (C) // - Adverbial (A) // - Determiner (D) // - Adjective (Adj) // - Preposition (P) // - Noun (N)

// Import the packages for natural language processing and random number generation package main

import (

"fmt"
"math/rand"
"time"

)

// Define the grammar rules as a map of slices

var grammar_rules = map[string][]string{
	"S":   {"NP VP", "NP VP A"},
	"NP":  {"D N", "D Adj N", "D N PP"},
	"VP":  {"V", "V NP", "V NP PP", "V NP C"},
	"PP":  {"P NP"},
	"C":   {"Adj", "PP"},
	"A":   {"Adv", "PP"},
	"D":   {"the", "a", "an"},
	"N":   {"cat", "dog", "book", "table", "chair", "man", "woman", "boy", "girl"},
	"V":   {"is", "has", "reads", "writes", "likes", "hates", "sees", "gives"},
	"Adj": {"big", "small", "red", "blue", "happy", "sad", "smart", "stupid"},
	"P":   {"on", "under", "in", "with", "to", "from", "for"},
	"Adv": {"quickly", "slowly", "loudly", "quietly", "well", "badly"},
}

// Define a function to generate a random sentence from the grammar

func generate_sentence(symbol string) string {
	// If the symbol is a terminal, return it as it is
	if _, ok := GrammarRules[symbol]; !ok {
		return symbol
	}
	// If the symbol is a non-terminal, choose a random production rule and apply it recursively
	rand.Seed(time.Now().UnixNano())
	rule := GrammarRules[symbol][rand.Intn(len(GrammarRules[symbol]))]
	sentence := ""
	for _, part := range split(rule, " ") {
		sentence += generate_sentence(part) + " "
	}
	return sentence
}

// Define a helper function to split a string by a separator

func split(str string, sep string) []string {
	result := []string{}
	start := 0
	for i := 0; i < len(str); i++ {
		if str[i:i+1] == sep {
			result = append(result, str[start:i])
			start = i + 1
		}
	}
	result = append(result, str[start:])
	return result
}

// Print 10 random sentences generated by the grammar

func main() {
	for i := 0; i < 10; i++ {
		fmt.Println(generate_sentence("S"))
	}
}

```

This document is result of this great wonderful ride of Generative Pre-trained Transformers. In order to make a worse version of what they do. Technology is truly magical. I used Bing Chat's Go code as a base and imposed my significant alteration of ChatGPT code on top of it (ChatGPT also originally had one of those small lists. They had very similar bases. Probably could have done this with just one of the models. Too late now).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL