zephyrtronium / robot

Robot is a Twitch bot that learns from people and responds to them with things that it has learned.
GNU General Public License v3.0
32 stars 5 forks source link

Setup / installation instructions #76

Open seth-rah opened 1 month ago

seth-rah commented 1 month ago

Hi there, trying to set up robot for a friend, but running into some issues, and I'm not sure what troubleshooting steps I should follow first as I don't see any instructions for getting robot set up for the first time

zephyrtronium commented 1 month ago

There is still a feature I intend to do that will eventually change setup instructions (#58), hence why there is nothing in the readme yet. That said, I'll give a rough outline of how to get started with the current version. I'm not sure what your level of expertise is, so feel free to ask follow-up questions.

  1. Create an application for your instance of the bot in the Twitch dev console.
    • The OAuth Redirect URL doesn't need to exist for now (again pending future changes), but your config will have to match what you enter.
    • Leave the client type as Confidential.
  2. Save the client secret Twitch shows you to a file. Keep the client ID on hand.
  3. With the Go toolchain installed and configured, run go install github.com/zephyrtronium/robot@master. (Without the @master, it will install the old version that has some performance and moderation issues.)
  4. Run robot -help to verify it's installed.
  5. Generate a secure random key. On Linux, you can do this with a command along the lines of head -c 32 /dev/random >robot_key && chmod 0400 robot_key, replacing robot_key with wherever you'd like to keep the key.
  6. Modify example.toml according to your needs.
    • Use the path to the key you generated in step 5 for the secret at the top of the file.
    • Use the path to the Twitch client secret you saved in step 2 for secret in the [tmi] section.
    • I highly recommend using the sqlbrain option in [db] rather than kvbrain.
  7. Run robot -config your.toml. If everything is configured correctly, it should prompt you to go to a URL to authorize your Robot instance.

Once all that is done, the bot should work.

seth-rah commented 1 month ago

I'll give it a go later, thanks. Will let you know if I run into any hiccups

seth-rah commented 1 month ago

Thanks, think I managed to get the setup done

will play around with this later

seth-rah commented 1 month ago

@zephyrtronium Question on this one

managed to set up the user and wanted to know, should I set up a db instance myself or is that done through the bot run?

I tried setting up the user, but not completely sure if I set everything up right myself

The user didn't auto-connect to a channel, so I made it join manually, and trying to use a say command to see if it's aware returned this error

time=2024-09-15T23:54:47.897+02:00 level=INFO msg="stream infos" count=0
time=2024-09-15T23:55:41.678+02:00 level=INFO msg=command level=any name=speak args=map[prompt:words] in=#finleyfisch
time=2024-09-15T23:55:41.681+02:00 level=ERROR msg="couldn't speak" err="couldn't speak: couldn't prepare term selection: sqlite: prepare \"SELECT id, suffix FROM knowledge WHERE tag = :tag AND prefix >= :lower AND prefix < :upper AND LIKELY(deleted IS NULL)\": SQL logic error: no such table: knowledge"

Although to be fair I kept this default

Should I change it to a path?

# db is a table of databases used by the bot.
# Exactly one of sqlbrain and kvbrain must be defined.
[db]
# sqlbrain is an SQLite3 connection string for the brain database.
# If sqlbrain is defined, the SQLite3 implementation is used.
sqlbrain = 'file:$ROBOT_SQLITE'
# kvbrain is the directory in which learned knowledge is stored.
# If kvbrain is defined, the Badger implementation is used.
#kvbrain = '$ROBOT_KNOWLEDGE'
# kvflag configures the brain database as a Badger "superflag" string.
# It is ignored when not using the Badger implementation.
#kvflag = ''
# privacy is an SQLite3 connection string for the database where privacy
# information is stored.
privacy = 'file:$ROBOT_SQLITE'
# spoken is an SQLite3 connection string for the database where generated
# message traces are stored.
spoken = 'file:$ROBOT_SQLITE'
seth-rah commented 1 month ago

Ok, I see what I did wrong here

So now I'm at a point where it's operational but I don't seem to see it learning anything

does the channel need to be live for it to interact with the DB?

image

time=2024-09-16T00:05:02.984+02:00 level=INFO msg="stream infos" count=0
time=2024-09-16T00:05:44.595+02:00 level=INFO msg=command level=any name=speak args=map[prompt:words] in=#finleyfisch
time=2024-09-16T00:05:44.600+02:00 level=INFO msg="spoke nothing" tag=bocchi prompt=words
time=2024-09-16T00:06:02.984+02:00 level=INFO msg="stream infos" count=0
time=2024-09-16T00:06:10.366+02:00 level=INFO msg=command level=any name=speak args=map[prompt:] in=#finleyfisch
time=2024-09-16T00:06:10.366+02:00 level=INFO msg="spoke nothing" tag=bocchi prompt=""
time=2024-09-16T00:06:15.901+02:00 level=INFO msg=command level=any name=speak args=map[prompt:] in=#finleyfisch
time=2024-09-16T00:06:15.901+02:00 level=INFO msg="spoke nothing" tag=bocchi prompt=""
time=2024-09-16T00:06:22.388+02:00 level=INFO msg=command level=any name=speak args="map[prompt:bocchi say words]" in=#finleyfisch
time=2024-09-16T00:06:22.388+02:00 level=INFO msg="spoke nothing" tag=bocchi prompt="bocchi say words"
time=2024-09-16T00:07:02.986+02:00 level=INFO msg="stream infos" count=0
time=2024-09-16T00:07:29.592+02:00 level=INFO msg=command level=any name=speak args="map[prompt:bocchi say words \U000e0000]" in=#finleyfisch
time=2024-09-16T00:07:29.592+02:00 level=INFO msg="spoke nothing" tag=bocchi prompt="bocchi say words \U000e0000"
time=2024-09-16T00:08:03.006+02:00 level=INFO msg="stream infos" count=0
time=2024-09-16T00:09:02.991+02:00 level=INFO msg="stream infos" count=0
time=2024-09-16T00:10:02.987+02:00 level=INFO msg="stream infos" count=0
time=2024-09-16T00:11:02.984+02:00 level=INFO msg="stream infos" count=0
zephyrtronium commented 1 month ago

Yes, the stream needs to be live for Robot to learn from it. The assumption is that offline chat is generally unmoderated, and Robot generally relies on moderators to keep its knowledge appropriate. I've considered adding a configuration option to override that behavior to help with testing an installation, but it's been low priority so far.

seth-rah commented 1 month ago

Gotcha, thanks for the help again

seth-rah commented 1 month ago

Sorry for bothering on a closed issue

Just trying to debug right now

So not sure if it's config related or not, or does robot have a minimum learning cycle

But right now robot isn't able to say anything in chat unless it's a copy-pasta. it will only repeat existing messages but never speak for itself

Any idea what might be the reason, even when stream is online

image

zephyrtronium commented 1 month ago

Robot should learn immediately, so there must be something off in the config. Do the values for learn and send on that channel match? If you open the database in the sqlite3 cli or the viewer of your choice, do you see entries in the knowledge table (SELECT COUNT(*) FROM knowledge;)?

I should also mention that my instance of Robot was indefinitely suspended without warning from Twitch for spam, so until such time as my appeal may be accepted, I won't be continuing development on this project. I'm still happy to help you get your instance working, of course, although I strongly recommend that you use it on a separate account from your own, preferably signed up with a different email address, if you aren't already doing that.

seth-rah commented 1 month ago

The knowledge table is definitely populating, and most of the config was kept as default minus some additions

image

[global.privileges]
twitch = [
  { name = 'nightbot', level = 'ignore' },
  { name = 'frostytoolbots', level = 'ignore' },
  { name = 'tangiabot', level = 'ignore' },
  { name = 'soundalerts', level = 'ignore' },
  { name = 'blerp', level = 'ignore' },
  { name = 'kofistreambot', level = 'ignore' },
  { name = 'streamelementsbot', level = 'ignore' },
]

[tmi]

cid = 'secretsshhhhh'

secret = 'D:\robot\twitchSecret'

redirect = 'http://localhost'

token = 'D:\robot\tmi_refresh'

owner = { id = '961395622', name = 'finleyfisch' }

rate = { every = 30, num = 20 }

[twitch.finleyfisch]

channels = ['#finleyfisch']

learn = 'finleyfisch'

send = 'bocchi'

block = '(?i)cucumber[^$x]'

responses = 0.02

rate = { every = 10.1, num = 2 }

copypasta = { need = 2, within = 30 }

privileges = [
  { name = 'sethrah', level = 'moderator' },
  { name = 'finleyfisch', level = 'moderator' },
]

[twitch.bocchi.emotes]
'btw make sure to stretch, hydrate, and take care of yourself <3' = 1

[twitch.bocchi.effects]
'AAAAA' = 44444
seth-rah commented 1 month ago

Oh, I think I understand what you meant with learn and send

Updating them

# learn is the tag used to learn Markov chain data from this channel.
learn = 'finleyfisch'
# send is the tag used to generate messages.
send = 'finleyfisch'

If this is what you meant, then I might have been confused by the comment

seth-rah commented 1 month ago

Yeah, that seems to have fixed it >.<

We created a new user for the bot so hopefully it won't get spam blocked.

We only have it learning and living in one channel