![]() ![]() The function on_connect will be called when we connect to a server. For example: c.add_global_handler("welcome", on_connect) The full list can be found here.Īdding a handler to an event means specifying what function should be called when a given event occurs. The irc library specifies a large number of events our program can react to. _channel() is a helper function that returns true when the given channel exists (so it's an actual channel, not some random string for example). ![]() It's best done in the on_connect handler. Now, this will only connect us to the server, but if we want to join a channel, we have to call the join method on the connection object that's received by the event handlers. You could either use reactor.process_forever() to use its internal loop, but in MO we'll require control over when the data is processed, so we'll have to call reactor.process_once() at scheduled intervals. connection.add_global_handler("welcome", on_connect)Ĭonnection.add_global_handler("join", on_join)Ĭonnection.add_global_handler("disconnect", on_disconnect)Ĭonnection.add_global_handler("pubmsg", on_pubmsg)Īnd finally, you will need the reactor object to process data it receives. They are explained in their own section on the wiki. Now you'll most likely want to add handlers for events. connection = rver().connect(server, port, nickname) ![]() Then you will need to create a connection object, with these 3 arguments. To connect to a server, you need to create an instance of the object. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |