jaraco / irc

Full-featured Python IRC library for Python.
MIT License
390 stars 84 forks source link

How to use data from one event handler in a different one? #227

Open ahopelesshadow opened 2 months ago

ahopelesshadow commented 2 months ago

I'm not sure if this is an issue as much of a question, its entirely possible I'm doing something wrong.

But lets say i write an event handler on_privmsg with

if event.arguments[0] == ".whois":
    whois = server.whois(event.arguments[1])
    userip = server.send_items("USERIP", event.arguments[1])
    server.privmsg(event.target, f"{whois} {userip}")

the issue here is while inside of that function, my event handlers for on_whois and on_iplookup do not fire, as the bot can only receive one response at a time. I wrote and defined the proper functions to parse out both whois and userip, and they both work, if i f10 through the entire program, but the problem there is my on_privmsg event has ended at that point... so when i go to reply with the variables in the fstring, they show as none...

So I guess my question is how can i get the data from those other two functions back into my privmsg function as the events wernt caught yet?

I did see another issue relating to whois, and the reply was to create a handler to catch and parse out the reply. I have done that and it works, but i cant seem to figure out how to use the data from that function.