@@ -52,7 +52,6 @@ def reply(self, text, private=False, hilight=False, strip_text=True):
5252 text = self .user + ": " + text
5353 self .bot .say (text , target = target , strip_text = strip_text )
5454
55-
5655class AbstractBot :
5756 """
5857 Base class for all bots backends. Define the common behaviour for the bot,
@@ -99,7 +98,7 @@ def __init__(
9998 :type local_only: bool
10099
101100 :example:
102- >>> Bot("Bot", {'#chan': AwesomePlugin()})
101+ >>> Bot("Bot", {'#chan': [ AwesomePlugin()] })
103102 """
104103 self .main_chan = main_chan
105104 self .nickname = nickname
@@ -118,6 +117,7 @@ def __init__(
118117 chans [chan ][k ] = chans [chan ].get (k , []) + list (v )
119118 self .channels = chans
120119 self .log = logging .getLogger (__name__ )
120+
121121
122122 def spawn (self , maybe_coroutine ):
123123 """
@@ -141,7 +141,7 @@ def connect(self, **kwargs):
141141 self .spawn (callback ())
142142 return self
143143
144- def feed (self , user , target , text ):
144+ def feed (self , user , target , text , sudo = False ):
145145 """
146146 Feed a new message into the bot
147147
@@ -155,18 +155,27 @@ def feed(self, user, target, text):
155155 # First check if the message was sent over a bridge by a bot.
156156 # If this is the case, extract the original author and text that was
157157 # sent on the other side of the bridge, and use them as user and text
158+
158159 if user in self .bridge_bots :
159- match = re .match (r"^\s*<\s*([^>]+)\s*>\s*(.+)" , text )
160+ self .log .debug ("msg from bridge" )
161+ match = re .match (r"^\s*\[\s*([^>]+)\s*\]\s*(.+)" , text )
160162 if match :
163+ self .log .debug ("command from bridge" + user )
161164 user = match .group (1 )
162165 text = match .group (2 )
166+
163167
164168 target = target .lower ()
165169 is_query = target [0 ] == "#"
170+ commands = []
166171 if is_query :
167- commands = self .channels .get (target , {}).get ("commands" , [])
172+ channel_callbacks = self .channels .get (target , {})
173+ commands = channel_callbacks .get ("commands" , [])
174+ if sudo :
175+ commands .extend (channel_callbacks .get ("sudo_commands" , []))
168176 else :
169177 commands = self .channels .get ("query" , {}).get ("commands" , [])
178+
170179 for (pattern , callback ) in commands :
171180 match = pattern .match (text )
172181 if match :
0 commit comments