rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
res = run_sql(query, params)
run_sql(query, params)
def subscribe_user_to_discussion(recID, uid): """ Subscribe a user to a discussion, so the she receives by emails all new new comments for this record. @param recID: record ID corresponding to the discussion we want to subscribe the user @param uid: user id """ query = """INSERT INTO cmtSUBSCRIPTION (id_bibrec, id_use...
self.reconnecting = False
def __init__(self, owner_bot, xmpp_room_jid, irc_room, irc_server, mode, say_level, irc_port=6667, irc_connection_interval=None, irc_charsets=None): """Create a new bridge.""" self.bot = owner_bot self.irc_server = irc_server self.irc_port = irc_port self.irc_room = irc_room.lower() self.irc_connection_interval = irc_c...
except ServerNotConnectedError:
except irclib.ServerNotConnectedError:
def _say_on_irc(self, message): try: self.irc_connection.privmsg(self.irc_room, message) except ServerNotConnectedError: bridges = self.bot.iter_bridges(irc_server=self.irc_server) self.bot.restart_bridges_delayed(bridges, 0, say_levels.error, 'Lost bot IRC connection', protocol='irc')
except ServerNotConnectedError: c = e.args[1]
except ServerNotConnectedError as e: if len(e.args) > 0: c = e.args[0] else: self.bot.error(say_levels.error, 'Unkonwn exception on IRC thread:\n'+str(e.args)) continue
def process_forever(self, timeout=0.2): """Run an infinite loop, processing data from connections.
self.irc_id = prefix if DEBUG: print "irc_id: %s" % (prefix)
if self.irc_id != prefix: self.irc_id = prefix if DEBUG: print "irc_id: %s" % (prefix)
def process_data(self): """[Internal]"""
if command in ["nick", "welcome"]: self.logged_in = True self.real_nickname = arguments[0] if self.new_nickname != arguments[0]: if len(self.new_nickname) > len(arguments[0]): self._handle_event(Event('nicknametoolong', None, None, None)) else: self._handle_event(Event('erroneusnickname', None, None, None)) else: self....
def process_data(self): """[Internal]"""
elif self.socket:
elif self.socket and hasattr(self.socket, 'recv'):
def process_data(self): """[Internal]"""
leave_message = 'kicked by '+nickname
leave_message = 'kicked by '+source_nickname
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if not self.mode:
if self.stopped:
def _irc_nick_callback(self, error, arguments=None): if not error: if not self.mode: return self.irc_connection.join(self.irc_room, callback=self._irc_join_callback) else: self.mode = None self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False) if error in ['nicknameinuse', 'nickcoll...
self.mode = None
self.stopped = True
def _irc_nick_callback(self, error, arguments=None): if not error: if not self.mode: return self.irc_connection.join(self.irc_room, callback=self._irc_join_callback) else: self.mode = None self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False) if error in ['nicknameinuse', 'nickcoll...
if not self.mode:
if self.stopped:
def _xmpp_join_callback(self, errors): """Called by muc._xmpp_presence_handler""" if len(errors) == 0: self.reconnecting = False if not self.mode: return self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self...
self.mode = None
self.stopped = True
def _xmpp_join_callback(self, errors): """Called by muc._xmpp_presence_handler""" if len(errors) == 0: self.reconnecting = False if not self.mode: return self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self...
self.error('==> Debug: Received XMPP message of unknown type "'+message.getType()+'".', debug=True)
self.error('==> Debug: Received XMPP message of unknown type "'+str(message.getType())+'".', debug=True)
def _xmpp_message_handler(self, dispatcher, message): """[Internal] Manage XMPP messages.""" xmpp_c = dispatcher._owner if message.getBody() == None: return if message.getType() == 'chat': from_bare_jid = unicode(message.getFrom().getNode()+'@'+message.getFrom().getDomain()) for bridge in self.bridges: if from_bare_...
raise Exception('[Error] unknown error for "'+self.bot.nickname+'" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0]))
raise Exception('[Error] unknown error for "'+self.bot.nickname+'" on bridge "'+str(self)+'"')
def _irc_nick_callback(self, error, arguments=[]): if error == None: if self.mode == None: return self.irc_connection.join(self.irc_room) self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on...
ret += ' - say_level='+bridge._say_levels[b.say_level]
ret += ' - say_level='+Bridge._say_levels[b.say_level]
def respond(self, message, participant=None, bot_admin=False): ret = '' command = shlex.split(message) args_array = [] if len(command) > 1: args_array = command[1:] command = command[0] if isinstance(participant, Participant) and bot_admin != participant.bot_admin: bot_admin = participant.bot_admin if command == 'xmp...
parser.add_argument('--mode', choices=bridge._modes, default='normal') parser.add_argument('--say-level', choices=bridge._say_levels, default='all')
parser.add_argument('--mode', choices=Bridge._modes, default='normal') parser.add_argument('--say-level', choices=Bridge._say_levels, default='all')
def respond(self, message, participant=None, bot_admin=False): ret = '' command = shlex.split(message) args_array = [] if len(command) > 1: args_array = command[1:] command = command[0] if isinstance(participant, Participant) and bot_admin != participant.bot_admin: bot_admin = participant.bot_admin if command == 'xmp...
bridges = self.findBridges(args_array)
bridges = self.findBridges(args_array[0])
def respond(self, message, participant=None, bot_admin=False): ret = '' command = shlex.split(message) args_array = [] if len(command) > 1: args_array = command[1:] command = command[0] if isinstance(participant, Participant) and bot_admin != participant.bot_admin: bot_admin = participant.bot_admin if command == 'xmp...
return 'No bridge found matching "'+' '.join(args_array)+'". '+self.respond('bridges')
return 'No bridge found matching "'+args_array[0]+'". '+self.respond('bridges')
def respond(self, message, participant=None, bot_admin=False): ret = '' command = shlex.split(message) args_array = [] if len(command) > 1: args_array = command[1:] command = command[0] if isinstance(participant, Participant) and bot_admin != participant.bot_admin: bot_admin = participant.bot_admin if command == 'xmp...
return 'More than one bridge matches "'+' '.join(args_array)+'", please be more specific. '+self.respond('bridges')
return 'More than one bridge matches "'+args_array[0]+'", please be more specific. '+self.respond('bridges')
def respond(self, message, participant=None, bot_admin=False): ret = '' command = shlex.split(message) args_array = [] if len(command) > 1: args_array = command[1:] command = command[0] if isinstance(participant, Participant) and bot_admin != participant.bot_admin: bot_admin = participant.bot_admin if command == 'xmp...
if isinstance(self.xmpp_c, xmpp.client.Client): self.bridge.bot.close_xmpp_connection(self.nickname) self.xmpp_c = None
self._close_xmpp_connection()
def _xmpp_join_callback(self, errors): if len(errors) == 0: m = '"'+self.nickname+'" duplicate succesfully created on XMPP side of bridge "'+str(self.bridge)+'"' if self.nickname != self.duplicate_nickname: m += ' using nickname "'+self.duplicate_nickname+'"' self.bridge.say(say_levels.info, '"'+self.nickname+'" will a...
if event.eventtype() == 'quit' and ( bridge.mode != 'normal' or isinstance(from_.irc_connection, irclib.ServerConnection) ): continue
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.disconnect("Connection reset by peer.")
self.disconnect("Connection reset by peer")
def send_raw(self, string): """Send raw string to the server.
self.disconnect("Connection reset by peer.")
self.disconnect("Connection reset by peer")
def privmsg(self, string): """Send data to DCC peer.
for bridge in [b for b in bridges]:
for bridge in self.bridges:
def findBridges(self, str_array): # TODO: lock self.bridges for thread safety bridges = [b for b in self.bridges] for bridge in [b for b in bridges]: for s in str_array: if not s in str(bridge): bridges.remove(bridge) break return bridges
self.error(say_levels.debug, 'a source is needed for a '+event.eventtype()+' event', no_debug_add=event_str) return if event.eventtype() == 'kick' and len(event.arguments()) == 0: self.error(say_levels.debug, 'at least 1 argument is needed for a '+event.eventtype()+' event', no_debug_add=event_str) return if event.ev...
self.error(say_levels.debug, 'a source is needed for a '+event.eventtype()+' event'+event_str) return if event.eventtype() in ['kick', 'mode'] and len(event.arguments()) == 0: self.error(say_levels.debug, 'at least 1 argument is needed for a '+event.eventtype()+' event'+event_str)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(2, debug_str, debug=True) self.error(say_levels.debug, 'a participant that was not here has been kicked ? WTF ?', no_debug_add=event_str)
self.error(say_levels.debug, 'a participant that was not here has been kicked ? WTF ?'+event_str)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if event.arguments()[1] != self.nickname or not 'o' in event.arguments()[0]: self.error(1, 'ignoring IRC mode "'+event.arguments()[0]+'" for "'+event.arguments()[1]+'"', debug=True) return if re.search('\+[^\-]*o', event.arguments()[0]): bridge.irc_op = True self.error(say_levels.notice, 'bot has IRC operator privileg...
if len(event.arguments()) == 1: self.error(1, 'ignoring IRC mode "'+event.arguments()[0]+'" for chan "'+event.target()+'"', debug=True) elif len(event.arguments()) == 2: if event.arguments()[1] != self.nickname or not 'o' in event.arguments()[0]: self.error(1, 'ignoring IRC mode "'+event.arguments()[0]+'" for "'+even...
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
sockets = filter(lambda x: x != None, sockets)
sockets = filter(lambda x: x and not isinstance(x, basestring), sockets)
def process_once(self, timeout=0): """Process data from connections once.
if not self.socket or self.socket == 'closed':
if not self.socket or isinstance(self.socket, basestring):
def send_raw(self, string): """Send raw string to the server.
elif self.socket and self.socket != 'closed':
else:
def send_raw(self, string): """Send raw string to the server.
if event.eventtype() in ['pubmsg', 'action', 'part', 'kick'] and not source_nickname:
if event.eventtype() in ['pubmsg', 'action', 'part', 'kick', 'join'] and not source_nickname:
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
bridge = self.get_bridge(irc_room=event.target().lower(), irc_server=connection.server)
if event.eventtype() == 'mode' and len(event.arguments()) < 2: self.error(say_levels.debug, '2 arguments are needed for a '+event.eventtype()+' event'+event_str) return chan = event.target().lower() bridge = self.get_bridge(irc_room=chan, irc_server=connection.server)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(say_levels.debug, 'a participant that wasn\'t here left:\n'+event_str)
self.error(say_levels.debug, 'a participant that wasn\'t here left:'+event_str)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if len(event.arguments()) < 2: self.error(say_levels.debug, '2 arguments are needed for a '+event.eventtype()+' event\n'+event_str) return
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
bridge = self.get_bridge(irc_room=event.target(), irc_server=connection.server)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(say_levels.notice, 'bot has IRC operator privileges in '+event.target())
self.error(say_levels.notice, 'bot has IRC operator privileges in '+chan)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(say_levels.notice, 'bot lost IRC operator privileges in '+event.target(), send_to_admins=True)
self.error(say_levels.notice, 'bot lost IRC operator privileges in '+chan, send_to_admins=True)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.lock.acquire()
def addParticipant(self, from_protocol, nickname, real_jid=None, irc_id=None): """Add a participant to the bridge.""" if (from_protocol == 'irc' and nickname == self.bot.nickname) or (from_protocol == 'xmpp' and nickname == self.bot.nickname): self.bot.error(3, 'not adding self ('+self.bot.nickname+') to bridge "'+str(...
except IOError: self.bot.error(3, 'IOError while adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'", reconnectiong ...', debug=True) p.xmpp_c.reconnectAndReauth()
def addParticipant(self, from_protocol, nickname, real_jid=None, irc_id=None): """Add a participant to the bridge.""" if (from_protocol == 'irc' and nickname == self.bot.nickname) or (from_protocol == 'xmpp' and nickname == self.bot.nickname): self.bot.error(3, 'not adding self ('+self.bot.nickname+') to bridge "'+str(...
if hasattr(self, 'reconnecting'): del self.reconnecting
self.reconnecting = False
def _xmpp_join_callback(self, errors): """Called by muc._xmpp_presence_handler""" if len(errors) == 0: if hasattr(self, 'reconnecting'): del self.reconnecting if self.mode == None: return self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) self.say(say_levels.notice, 'bridge "'...
if (from_protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (from_protocol == 'xmpp' and nickname == self.xmpp_room.nickname):
if (from_protocol == 'irc' and nickname == self.bot.nickname) or (from_protocol == 'xmpp' and nickname == self.bot.nickname):
def addParticipant(self, from_protocol, nickname, real_jid=None, irc_id=None): """Add a participant to the bridge.""" if (from_protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (from_protocol == 'xmpp' and nickname == self.xmpp_room.nickname): self.bot.error('===> Debug: not adding self ('+self.b...
def restart(self, log=True):
def restart(self, message='Restarting bridge', log=True):
def restart(self, log=True): """Restart the bridge""" # Stop the bridge self.stop(message='Restarting bridge', log=log) # Recreate the bridge self.init2()
self.stop(message='Restarting bridge', log=log)
self.stop(message=message, log=log)
def restart(self, log=True): """Restart the bridge""" # Stop the bridge self.stop(message='Restarting bridge', log=log) # Recreate the bridge self.init2()
try: bot_say = False if message[:4] == '/me ': action = True message = message[4:] else: action = False if isinstance(self.irc_connection, ServerConnection): try: if action: self.irc_connection.action(self.bridge.irc_room, message) else: self.irc_connection.privmsg(self.bridge.irc_room, message) except ServerNotConnect...
bot_say = False if message[:4] == '/me ': action = True message = message[4:] else: action = False if isinstance(self.irc_connection, ServerConnection): try: if action: self.irc_connection.action(self.bridge.irc_room, message) else: self.irc_connection.privmsg(self.bridge.irc_room, message) except ServerNotConnectedErr...
def sayOnIRC(self, message): try: bot_say = False if message[:4] == '/me ': action = True message = message[4:] else: action = False if isinstance(self.irc_connection, ServerConnection): try: if action: self.irc_connection.action(self.bridge.irc_room, message) else: self.irc_connection.privmsg(self.bridge.irc_room, mes...
if bot_say: if action: self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message) else: self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) except EncodingException: self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an u...
elif not isinstance(self.xmpp_c, xmpp.client.Client): bot_say = True if bot_say: if action: self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message) else: self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
def sayOnIRC(self, message): try: bot_say = False if message[:4] == '/me ': action = True message = message[4:] else: action = False if isinstance(self.irc_connection, ServerConnection): try: if action: self.irc_connection.action(self.bridge.irc_room, message) else: self.irc_connection.privmsg(self.bridge.irc_room, mes...
try: self.irc_connection.privmsg(to, message) except EncodingException: self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an unknown encoding', log=True)
self.irc_connection.privmsg(to, message)
def sayOnIRCTo(self, to, message): if isinstance(self.irc_connection, ServerConnection): try: self.irc_connection.privmsg(to, message) except EncodingException: self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an unknown encoding', log=True) elif not isinstance(self.xmpp_c, xmpp.client...
try: if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.say(message) elif not isinstance(self.irc_connection, ServerConnection): if message[:4] == '/me ': self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:]) else: self.bridge.xmpp_room.say('<'+self.nickname+'> '+message) except EncodingException: self.br...
if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.say(message) elif not isinstance(self.irc_connection, ServerConnection): if message[:4] == '/me ': self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:]) else: self.bridge.xmpp_room.say('<'+self.nickname+'> '+message)
def sayOnXMPP(self, message): try: if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.say(message) elif not isinstance(self.irc_connection, ServerConnection): if message[:4] == '/me ': self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:]) else: self.bridge.xmpp_room.say('<'+self.nickname+'> '+message) exc...
try: if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.sayTo(to, message) elif not isinstance(self.irc_connection, ServerConnection): if self.bridge.mode != 'normal': self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') ...
if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.sayTo(to, message) elif not isinstance(self.irc_connection, ServerConnection): if self.bridge.mode != 'normal': self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') else:...
def sayOnXMPPTo(self, to, message): try: if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.sayTo(to, message) elif not isinstance(self.irc_connection, ServerConnection): if self.bridge.mode != 'normal': self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disab...
if not self.connected: return
def disconnect(self, message="", volontary=False): """Hang up the connection.
self.connected = False self.quit(message) try: self.socket.close() except socket.error, x: pass self.socket = 'closed'
if self.connected: self.connected = False if self.socket and self.socket != 'closed': self.quit(message) try: self.socket.close() except socket.error, x: pass self.socket = 'closed'
def disconnect(self, message="", volontary=False): """Hang up the connection.
try: from_ = bridge.get_participant(source_nickname) except Bridge.NoSuchParticipantException: from_ = None
from_ = None if source_nickname: try: from_ = bridge.get_participant(source_nickname) except Bridge.NoSuchParticipantException: pass
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
for i in range(math.ceil(l_size/available_size)):
for i in range(int(math.ceil(l_size/available_size))):
def privmsg(self, target, text): """Send a PRIVMSG command.""" for l in text.split('\n'): l_size = len(l.encode('utf-8')) available_size = float(510-len('%s PRIVMSG %s :' % (self.irc_id, target))) # 510 is the size limit for IRC messages defined in RFC 2812 e = 0 for i in range(math.ceil(l_size/available_size)): s = e...
self.stop(message='Failed to connect to the XMPP room, stopping bridge')
self.stop(message='Failed to connect to the XMPP room, stopping bridge', log=False)
def _xmpp_join_callback(self, errors): """Called by muc._xmpp_presence_handler""" if len(errors) == 0: self.reconnecting = False if not self.mode: return self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self...
raise UnknownChannel, (channels, message, self)
raise UnknownChannel, (channels, message, str(self))
def part(self, channels, message=""): """Send a PART command.""" try: if isinstance(channels, basestring): try: self.channels[channels].part(message=message) except KeyError: raise UnknownChannel, (channels, message, self) else: for channel in channels: try: self.channels[channel].part(message=message) except KeyError:...
nickname = None
source_nickname = None
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
nickname = event.source().split('!')[0]
source_nickname = event.source().split('!')[0]
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
printed_event = False if event.eventtype() in ['pubmsg', 'action', 'privmsg', 'quit', 'part', 'nick', 'kick']: if nickname == None: return handled = False if event.eventtype() in ['quit', 'part'] and nickname == self.nickname: return if event.eventtype() in ['quit', 'part', 'nick', 'kick']: if connection.real_nick...
handled = False if event.eventtype() in ['privmsg', 'action']: if event.target() == self.nickname: connection.privmsg(source_nickname, self.respond(event.arguments()[0])) return elif not irclib.is_channel(event.target()[0]): for bridge in self.iter_bridges(irc_server=connection.server):
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
to_ = bridge.get_participant(event.target().split('!')[0]) self.error(2, debug_str, debug=True) from_.say_on_xmpp_to(to_.nickname, event.arguments()[0]) return except Bridge.NoSuchParticipantException: if event.target().split('!')[0] == self.nickname: self.error(2, debug_str, debug=True) connection.privmsg(from_.nick...
from_ = bridge.get_participant(source_nickname)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
from_.say_on_xmpp(message, action=action)
from_.say_on_xmpp_to(connection.nickname, event.arguments()[0], action=action)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
continue
leave_message = 'Left server.' bridge.remove_participant('irc', from_.nickname, leave_message) continue if event.eventtype() == 'nick': from_.change_nickname(event.target(), 'xmpp') continue
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if event.eventtype() in ['namreply', 'join']: if event.eventtype() == 'namreply': bridge = self.get_bridge(irc_room=event.arguments()[1].lower(), irc_server=connection.server) for nickname in re.split('(?:^[&@\+%]?|(?: [&@\+%]?)*)', event.arguments()[2].strip()): if nickname == '' or nickname == self.nickname: continue...
if event.eventtype() in ['pubmsg', 'action', 'part', 'kick', 'mode', 'join']: if event.eventtype() in ['pubmsg', 'action', 'part', 'kick'] and not source_nickname: self.error(say_levels.debug, 'a source is needed for a '+event.eventtype()+' event', no_debug_add=event_str) return if event.eventtype() == 'kick' and len...
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
return if event.eventtype() == 'mode': if len(event.arguments()) < 2: self.error(2, debug_str, debug=True) self.error(1, '2 arguments are needed for a '+event.eventtype()+' event', debug=True) return if event.arguments()[1] != self.nickname or not 'o' in event.arguments()[0]: self.error(1, 'ignoring IRC mode "'+even...
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if not printed_event: self.error(say_levels.debug, 'The following IRC event was not handled:'+event_str+'\n', send_to_admins=True) else: self.error(1, 'event not handled', debug=True) self._send_message_to_admins(say_levels.debug, 'The following IRC event was not handled:'+event_str)
self.error(1, 'event not handled', debug=True) self._send_message_to_admins(say_levels.debug, 'The following IRC event was not handled:'+event_str)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(2, debug_str, debug=True) self.error(say_levels.debug, '2 arguments are needed for a '+event.eventtype()+' event', no_debug_add=event_str)
self.error(say_levels.debug, '2 arguments are needed for a '+event.eventtype()+' event\n'+event_str)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.really_connected == True or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc):
if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.really_connected == True and p.irc_connection.real_nickname == nickname or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc) and p.xmpp_c.nickname == nickname:
def addParticipant(self, from_protocol, nickname, real_jid=None, irc_id=None): """Add a participant to the bridge.""" if (from_protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (from_protocol == 'xmpp' and nickname == self.xmpp_room.nickname): self.bot.error('===> Debug: not adding self ('+self.b...
self.__del__()
self.stop()
def respond(self, message, participant=None, bot_admin=False): ret = '' command = shlex.split(message) args_array = [] if len(command) > 1: args_array = command[1:] command = command[0] if isinstance(participant, Participant) and bot_admin != participant.bot_admin: bot_admin = participant.bot_admin if command == 'xmp...
return 'Bot stopped.'
return
def stop_bot(bot, command, args_array, bridge): bot.stop() return 'Bot stopped.'
self.quit(message)
if message and message != 'Connection reset by peer': self.quit(message)
def disconnect(self, message="", volontary=False): """Hang up the connection.
if isinstance(p.muc, xmpp.muc) and not xmpp.muc.connected:
if isinstance(p.muc, xmpp.muc) and not p.muc.connected:
def remove_participant(self, left_protocol, nickname, leave_message): """Remove the participant using nickname from the bridge. Raises a NoSuchParticipantException if nickname is not used in the bridge.""" was_on_both = None p = self.get_participant(nickname) if p.left: self.lock.acquire() self.participants.remove(p)...
p.irc_connection = error
p.irc_connection = event.eventtype()
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
trace = traceback.format_exc().splitlines()[-1] self.bot.error(say_levels.error, 'failed to connect to the XMPP room of bridge "'+str(self)+'", stopping bridge\n'+trace, send_to_admins=True)
trace += '\n'+traceback.format_exc().splitlines()[-1] self.bot.error(say_levels.error, 'failed to connect to the XMPP room of bridge "'+str(self)+'", stopping bridge'+trace, send_to_admins=True)
def _xmpp_join_callback(self, errors): """Called by muc._xmpp_presence_handler""" if len(errors) == 0: self.reconnecting = False if self.stopped: return self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self....
if self.socket is None:
if not self.socket or self.socket == 'closed':
def send_raw(self, string): """Send raw string to the server.
else:
elif self.socket and self.socket != 'closed':
def send_raw(self, string): """Send raw string to the server.
self.error(3, 'event target ('+event.target()+') and connection nickname ('+connection.nickname+') don\'t match')
self.error(3, 'event target ('+event.target()+') and connection nickname ('+connection.nickname+') don\'t match', debug=True)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(1, 'a participant that was not here has been kicked ? WTF ?')
self.error(1, 'a participant that was not here has been kicked ? WTF ?', debug=True)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(1, 'length of arguments should be greater than 0 for a '+event.eventtype()+' event')
self.error(1, 'length of arguments should be greater than 0 for a '+event.eventtype()+' event', debug=True)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(1, 'no such participant. WTF ?')
self.error(1, 'no such participant. WTF ?', debug=True)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self.error(2, debug_str, send_to_admins=True)
self.error(say_levels.debug, debug_str, send_to_admins=True)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
self._send_message_to_admins('[Debug] The following IRC event was not handled:\n'+event_str)
self._send_message_to_admins(say_levels.debug, 'The following IRC event was not handled:\n'+event_str)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if isinstance(self.muc, xmpp.muc) and self.muc.connected:
if isinstance(self.muc, xmpp.muc):
def _xmpp_join_callback(self, errors): if len(errors) == 0: m = '"'+self.nickname+'" duplicate succesfully created on XMPP side of bridge "'+str(self.bridge)+'"' if self.nickname != self.duplicate_nickname: m += ' using nickname "'+self.duplicate_nickname+'"' self.bridge.say(say_levels.info, '"'+self.nickname+'" will a...
self.disconnect(message, volontary)
def close(self, message, volontary=True): """Close the connection.
new_data = self.socket.recv(2**14)
return
def process_data(self): """[Internal]"""
self._close_xmpp_connection()
self._close_xmpp_connection('')
def _xmpp_join_callback(self, errors): if len(errors) == 0: m = '"'+self.nickname+'" duplicate succesfully created on XMPP side of bridge "'+str(self.bridge)+'"' if self.nickname != self.duplicate_nickname: m += ' using nickname "'+self.duplicate_nickname+'"' self.bridge.say(say_levels.info, '"'+self.nickname+'" will a...
kicked.leave(m)
kicked.leave(leave_message)
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if isinstance(self.xmpp_c, xmpp.client.Client):
if self.muc.connected:
def say_on_xmpp(self, message, action=False): if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.say(message, action=action) elif not isinstance(self.irc_connection, ServerConnection): self.bridge.say_on_behalf(self.nickname, message, 'xmpp', action=action)
if isinstance(self.xmpp_c, xmpp.client.Client):
if self.muc.connected:
def say_on_xmpp_to(self, to, message, action=False): if isinstance(self.xmpp_c, xmpp.client.Client): self.muc.say_to(to, message, action=action) elif not isinstance(self.irc_connection, ServerConnection): if self.bridge.mode not in ['normal', 'bypass']: self.bridge.get_participant(to).say_on_xmpp_to(self.nickname, 'XIB...
message = self.bot.format_message(importance, message)
def say(self, importance, message, on_irc=True, on_xmpp=True, log=False, send_to_admins=False): """Make the bot say something.""" message = self.bot.format_message(importance, message) if log or send_to_admins: self.bot.error(importance, message+' ('+str(self)+')', send_to_admins=send_to_admins) if importance < self.sa...
if event.eventtype() in ['pong', 'privnotice', 'ctcp', 'nochanmodes', 'notexttosend', 'currenttopic', 'topicinfo', '328', 'pubnotice', '042', 'umode', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown', 'lu...
if event.eventtype() in ['pong', 'privnotice', 'ctcp', 'nochanmodes', 'notexttosend', 'currenttopic', 'topicinfo', '328', 'pubnotice', '042', 'umode', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown', 'lu...
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if event.eventtype() == 'bannedfromchan': if len(event.arguments()) < 1: self.error(1, 'length of arguments should be greater than 0 for a '+event.eventtype()+' event', debug=True) return for bridge in self.bridges: if connection.server != bridge.irc_server or event.arguments()[0].lower() != bridge.irc_room: continue ...
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
if event.eventtype() in ['cannotsendtochan', 'notonchannel', 'inviteonlychan']:
if event.eventtype() in ['cannotsendtochan', 'notonchannel']:
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
bridges = self.iter_bridges(irc_room=event.arguments()[0], irc_server=connection.server) if len(bridges) > 1: raise Exception, 'more than one bridge for one irc chan, WTF ?' bridge = bridges[0] if connection.real_nickname == self.nickname: bridge._join_irc_failed(event.eventtype()) else: p = bridge.get_participant(conn...
bridge = self.get_bridge(irc_room=event.arguments()[0], irc_server=connection.server) if event.eventtype() == 'cannotsendtochan': if connection.real_nickname == self.nickname: bridge._join_irc_failed(event.eventtype()) else: p = bridge.get_participant(connection.real_nickname) p._close_irc_connection(event.eventtype()...
def _irc_event_handler(self, connection, event): """[Internal] Manage IRC events""" # Answer ping if event.eventtype() == 'ping': connection.pong(connection.get_server_name()) return # Events we always want to ignore if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse...
def disconnect_all(self, message=""):
def disconnect_all(self, message="", volontary=True):
def disconnect_all(self, message=""): """Disconnects all connections.""" for c in self.connections: c.disconnect(message)
c.disconnect(message)
c.disconnect(message, volontary=volontary)
def disconnect_all(self, message=""): """Disconnects all connections.""" for c in self.connections: c.disconnect(message)
ret += r
ret += r+'\n'
def change_bridges_mode(bot, command, args_array, bridge): parser = ArgumentParser(prog=command) parser.add_argument('bridge_id', nargs='+') parser.add_argument('new_mode', choices=Bridge._modes) try: args = parser.parse_args(args_array) except ArgumentParser.ParseException as e: return '\n'+e.args[1] found_bridges, r...
Plus just '+' or '-' signs can be used but cap at 3 multiples to protect layout<br/
Plus just '+' or '-' signs can be used but cap at 3 multiples to protect layout<br/>
def __unicode__(self): return '%s : %s' % (self.grid.slug, self.title)
supported = models.BooleanField(_("Does Django Packages support this repo site?"), default=False)
def __unicode__(self): return self.title
ordering = ['-supported', 'title']
ordering = ['-is_supported', 'title']
def __unicode__(self): return self.title
if not self.supported:
if not self.is_supported:
def __unicode__(self): if not self.supported: return '%s (unsupported)' % self.title return self.title
@login_required
def update_package(request, slug): package = get_object_or_404(Package, slug=slug) package.fetch_metadata() return HttpResponseRedirect(reverse("package", kwargs={"slug": package.slug}))
@login_required
def add_example(request, slug, template_name="package/add_example.html"): package = get_object_or_404(Package, slug=slug) new_package_example = PackageExample() form = PackageExampleForm(request.POST or None, instance=new_package_example) if form.is_valid(): package_example = PackageExample(package=package, title=req...