@@ -123,15 +123,15 @@ def message_handler(self, data):
123123 data ["user_name" ], "Please stop posting links." ,
124124 method = "whisper" )
125125
126- if parsed [0 ].startswith ("!" ) and len ( parsed ) > 1 :
126+ if len ( parsed ) > 1 and parsed [0 ].startswith ("!" ):
127127 args = parsed .split ()
128128
129129 if args [0 ][1 :] in self .commands :
130130 response = self .commands [args [0 ][1 :]]
131131 if isinstance (response , str ):
132- message = response
132+ messages = response
133133 else :
134- message = response (args , data )
134+ messages = response (args , data )
135135 else :
136136 options = [
137137 ('-' .join (args [:2 ])[1 :], ['-' .join (args [:2 ])] + args [2 :]),
@@ -142,19 +142,23 @@ def message_handler(self, data):
142142 command = session .query (
143143 Command ).filter_by (command = parse_method [0 ]).first ()
144144 if command :
145- message = command (
145+ messages = command (
146146 parse_method [1 ], data ,
147147 channel_name = self .channel_data ["token" ]
148148 )
149149 break
150150 else :
151- message = "Command not found."
151+ messages = "Command not found."
152+
153+ if isinstance (messages , str ):
154+ messages = (messages ,)
152155
153156 if data ["message" ]["meta" ].get ("whisper" , False ):
154- return self .send_message (
155- data ["user_name" ], message , method = "whisper" )
157+ for message in messages :
158+ self .send_message (
159+ data ["user_name" ], message , method = "whisper" )
156160 else :
157- return self .send_message (message )
161+ self .send_message (* messages )
158162
159163 def join_handler (self , data ):
160164 """Handle user join packets from Beam."""
0 commit comments