mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
adding buddy detection, sanitize urls for urlbot
This commit is contained in:
16
plugins.py
16
plugins.py
@@ -978,6 +978,22 @@ def recognize_bots(**args):
|
|||||||
'msg': 'Making notes...'
|
'msg': 'Making notes...'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elif 'I\'ll be back' in args['data']:
|
||||||
|
# a buddy!
|
||||||
|
blob = conf_load()
|
||||||
|
|
||||||
|
if 'other_bots' not in blob:
|
||||||
|
blob['other_bots'] = []
|
||||||
|
if args['reply_user'] not in blob['other_bots']:
|
||||||
|
blob['other_bots'].append(args['reply_user'])
|
||||||
|
conf_save(blob)
|
||||||
|
return {
|
||||||
|
'event': {
|
||||||
|
'time': time.time() + 3,
|
||||||
|
'msg': 'Hey there, buddy!'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pluginfunction("set_status", "set bot status", ptypes_COMMAND)
|
@pluginfunction("set_status", "set bot status", ptypes_COMMAND)
|
||||||
|
|||||||
11
urlbot.py
11
urlbot.py
@@ -123,10 +123,20 @@ class UrlBot(IdleBot):
|
|||||||
if str is not type(message):
|
if str is not type(message):
|
||||||
message = '\n'.join(message)
|
message = '\n'.join(message)
|
||||||
|
|
||||||
|
# check other bots, add nospoiler with urls
|
||||||
|
def _prevent_panic(message, room):
|
||||||
|
if 'http' in message:
|
||||||
|
other_bots = conf_load().get("other_bots", ())
|
||||||
|
users = self.plugin['xep_0045'].getRoster(room)
|
||||||
|
if set(users).intersection(set(other_bots)):
|
||||||
|
message = '(nospoiler) %s' % message
|
||||||
|
return message
|
||||||
|
|
||||||
if conf('debug_mode', False):
|
if conf('debug_mode', False):
|
||||||
print(message)
|
print(message)
|
||||||
else:
|
else:
|
||||||
if msg_obj:
|
if msg_obj:
|
||||||
|
message = _prevent_panic(message, msg_obj['from'].bare)
|
||||||
self.send_message(
|
self.send_message(
|
||||||
mto=msg_obj['from'].bare,
|
mto=msg_obj['from'].bare,
|
||||||
mbody=message,
|
mbody=message,
|
||||||
@@ -134,6 +144,7 @@ class UrlBot(IdleBot):
|
|||||||
)
|
)
|
||||||
else: # unset msg_obj == broadcast
|
else: # unset msg_obj == broadcast
|
||||||
for room in self.rooms:
|
for room in self.rooms:
|
||||||
|
message = _prevent_panic(message, room)
|
||||||
self.send_message(
|
self.send_message(
|
||||||
mto=room,
|
mto=room,
|
||||||
mbody=message,
|
mbody=message,
|
||||||
|
|||||||
Reference in New Issue
Block a user