python-gsoc / python-blogs

Python Software Foundation GSoC Blog Platform. This system was used until 2024 but is no longer maintained.
http://python-gsoc.org/
GNU Affero General Public License v3.0
41 stars 60 forks source link

GSoC 2019 - Send IRC Message to Bot #6

Closed botanicvelious closed 5 years ago

botanicvelious commented 5 years ago

This task involves writing the base code necessary to send a message to the in the #python-gsoc channel on @freenode IRC.

sounak98 commented 5 years ago

@botanicvelious does this bot need to send occasional messages (one or two messages and then disconnect) or does it need to stay active and respond to messages from other users?

botanicvelious commented 5 years ago

This code would be to send messages -to- the bot to configure it. For example when a new sub-org is added it would send to PyGSOCBot the messages below based on the items in the suborg form

@messageparser add global "(?i)suborg list" "echo The 2019 suborgs are MNE-Python, PySAL, PSF GSoC Team, SciPy, StarKit, Nuitka, MSS - Mission Support System, EOS Design System, Scrapy, Statsmodels, Buildbot, CVE Binary Tool, Mercurial, <new org>!"
@messageparser add global "(?i)what is <new org>" "echo <new org>is an open-source ..."
@messageparser add global "(?i)contact <new org>" "echo Please see http://<new org>/contact.html"
@messageparser add global "(?i)<new org> ideas" "echo Please see https://<new org>/GSoC-Projects-2019"
sounak98 commented 5 years ago

So basically the code needs to run when a new sub-org is added or events like that. This code doesn't need to listen for messages, it just needs to send commands to the other bots present in the channel. Am I right @botanicvelious?

botanicvelious commented 5 years ago

That is correct, this would just send messages to the limnoria bot which handles all the replies etc

botanicvelious commented 5 years ago

Note: for messages more than 202 characters, you would need to send it in pieces like below

@aka add msg1 "echo looooooong"
@aka add msg2 "echo messaaaaage"
@messageparser add global "(?i)test list" [echo echo [msg1] [msg2]]
@aka remove msg1
@aka remove msg2
sounak98 commented 5 years ago

@messageparser add global "(?i)test list" [echo echo [msg1] [msg2]]

Do you mean the final message that needs to be sent for the corresponding message above is '@messageparser add global "(?i)test list" [echo echo [msg1] [msg2]]'?

And also do you think we should use a light-weight framework like FredIRC or write a low-level implementation for the same purpose? The plus point for using FredIRC is that it is event-driven and so we can easily send the commands when joined and disconnect when the purpose is served (the commands are sent).

botanicvelious commented 5 years ago

That sounds fine, for the longer messages irc pm's only allow 202 characters, as such you have to add an aka. This makes the bot replace msg1 internally with the aka

the format is exactly as above, so see below examples

<202 chars
@aka add msg1 "echo looooooong"
@messageparser add global "(?i)test list" [echo [msg1]]
@aka remove msg1
>202 < 404 chars
@aka add msg1 "echo looooooong"
@aka add msg2 "echo messaaaaage"
@messageparser add global "(?i)test list" [echo echo [msg1] [msg2]]
@aka remove msg1
@aka remove msg2
>404 < 606 chars
@aka add msg1 "echo reallllllly"
@aka add msg2 "echo looooooong"
@aka add msg3 "echo messaaaaage"
@messageparser add global "(?i)test list" [echo echo echo [msg1] [msg2] [msg3]]
@aka remove msg1
@aka remove msg2
@aka remove msg3

etc etc

Note: the "test list" would need to be a variable as that is the string the bot responds on