I’m trying to learn the basics of creating a chatbot. (I’m using the Python example bot as a basis) For one of the bot’s functions, it needs to be able to get the username of whoever entered a command. For instance,
def do_command(self, e, cmd):
c = self.connection
if cmd == "hello":
message = "Hello, " + username + "!"
In this example function, how can I put the name of the user who entered the ‘!hello’ command into the ‘username’ string?
Sorry if this question is too simplistic, but I’m struggling to find documentation for this stuff that I’m actually able to understand.
This chat example uses,
jaraco/irc as a basic IRC library
Yon can log out the contents of
e to see what it has exposed.
It’s probably in
e.login, I don’t use python or this library myself
But this is more a IRC parsing question in python than a TwitchAPI question.
Thank you! I’ll look into that documentation. I didn’t think this was the right category for it either, but I didn’t know what the correct category should have been.
e.source.nick for the user’s logon name
If you need the displayed name, you’ll have to get it from e.tags (key=“display_name”)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.