update post_connect to accept a /command to do things other than "msg"

these are just /msg and /mode for now, and the slash is retained out of
convention

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
Brian S. Stephan 2024-12-16 23:47:32 -06:00
parent 166b506843
commit d0cbc815d1
Signed by: bss
GPG Key ID: 3DE06D3180895FCB

View File

@ -537,9 +537,13 @@ class IRCBot(irc.client.SimpleIRCClient):
# run automsg commands
if self.server_config.post_connect:
for cmd in self.server_config.post_connect.split('\n'):
cmd_split = cmd.split(' ')
# TODO NOTE: if the bot is sending something that changes the vhost
# (like 'hostserv on') we don't pick it up
self.connection.privmsg(cmd.split(' ')[0], ' '.join(cmd.split(' ')[1:]))
if cmd_split[0] == '/msg':
self.connection.privmsg(cmd.split(' ')[1], ' '.join(cmd.split(' ')[2:]))
elif cmd_split[0] == '/mode':
self.connection.mode(*cmd_split[1:])
# sleep before doing autojoins
time.sleep(self.server_config.delay_before_joins)