only run commands in pubmsg if the bot has been addressed
This commit is contained in:
parent
d1d54ca35c
commit
f6319244c8
14
dr.botzo.py
14
dr.botzo.py
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
|
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import irclib
|
import irclib
|
||||||
|
@ -83,7 +84,7 @@ def on_connect(connection, event):
|
||||||
# user modes
|
# user modes
|
||||||
try:
|
try:
|
||||||
usermode = config.get('IRC', 'usermode')
|
usermode = config.get('IRC', 'usermode')
|
||||||
connection.mode(nick, usermode)
|
connection.mode(botnick, usermode)
|
||||||
except NoOptionError: pass
|
except NoOptionError: pass
|
||||||
|
|
||||||
# join the specified channels
|
# join the specified channels
|
||||||
|
@ -136,6 +137,17 @@ def on_pubmsg(connection, event):
|
||||||
admin_unlocked = True
|
admin_unlocked = True
|
||||||
except NoOptionError: pass
|
except NoOptionError: pass
|
||||||
|
|
||||||
|
# only do commands if the bot has been addressed directly
|
||||||
|
addressed_pattern = '^' + botnick + '[:,]?\s+'
|
||||||
|
addressed_re = re.compile(addressed_pattern)
|
||||||
|
|
||||||
|
if not addressed_re.match(what):
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
what = addressed_re.sub('', what)
|
||||||
|
|
||||||
|
print("could be a command: " + what)
|
||||||
|
|
||||||
# admin commands
|
# admin commands
|
||||||
sub_join_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
sub_join_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||||
sub_part_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
sub_part_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||||
|
|
Loading…
Reference in New Issue