\n' % (paste_header,lht,lht)][_html_paste]
+ fl = open(pastepath+url, 'a')
+ fl.write(paste_he.encode('utf-8'))
+ fl.write(paste_body.encode('utf-8'))
+ paste_ender = ['','
'][_html_paste]
+ fl.write(paste_ender.encode('utf-8'))
+ fl.close()
+ return pasteurl+url
+
+def disp_time(*t):
+ if len(t) == 2: rn = t[1]
+ else: rn = ''
+ t = t[0]
+ lt=tuple(time.localtime(t))
+ return '%02d:%02d:%02d, %02d.%s\'%s, %s' % (lt[3],lt[4],lt[5],lt[2],L(wmonth[lt[1]-1],rn).replace('_',''),lt[0],L(wday[lt[6]],rn))
+
+def nice_time(*ttim):
+ if len(ttim) == 2: rn = ttim[1]
+ else: rn = ''
+ ttim = ttim[0]
+ gt=tuple(time.gmtime(ttim))
+ lt=tuple(time.localtime(ttim))
+ timeofset = (datetime.datetime(*lt[:6])-datetime.datetime(*gt[:6])).seconds / 3600.0
+ if timeofset < 0: t_gmt = 'GMT%s' % int(timeofset)
+ else: t_gmt = 'GMT+%s' % int(timeofset)
+ if timeofset%1: t_gmt += ':%02d' % int((timeofset%1*60/100) * 100)
+ t_utc='%s%02d%02dT%02d:%02d:%02d' % gt[:6]
+ t_display = '%02d:%02d:%02d, %02d.%s\'%s, %s, ' % (lt[3],lt[4],lt[5],lt[2],L(wmonth[lt[1]-1],rn).replace('_',''),lt[0],L(wday[lt[6]],rn))
+ #t_tz = time.tzname[time.localtime()[8]]
+ #enc = chardet.detect(t_tz)['encoding']
+ #if t_tz == None: body = ''
+ #if enc == None or enc == '' or enc.lower() == 'unicode': enc = 'utf-8'
+ #t_tz = unicode(t_tz,enc)
+ #t_display += '%s, %s' % (t_tz,t_gmt)
+ #return t_utc,t_tz,t_display
+ t_display += t_gmt
+ return t_utc,t_gmt,t_display
+
+def get_eval_item(mess,string):
+ try:
+ result = eval('mess.%s' % string)
+ if result: return result.encode('utf-8')
+ except: pass
+ return ''
+
+def match_for_raw(original,regexp,gr):
+ orig_drop = orig_reg = re.findall(regexp, original.replace('\n',' '), re.S|re.I|re.U)
+ while '' in orig_drop: orig_drop.remove('')
+ orig_join = ''.join(orig_reg)
+ if orig_join:
+ #orig_split = original.split()
+ #match_percent = 100.0 / len(original) * len(orig_join)
+ #match_percent = 100.0 / len(orig_drop) * len(orig_split)
+ match_percent = 100.0 / len(orig_drop) * sum([len(tmp) <= 2 for tmp in orig_drop])
+
+ raw_percent = get_config(gr,'muc_filter_raw_percent')
+ if raw_percent.isdigit(): raw_percent = int(raw_percent)
+ else: raw_percent = int(config_prefs['muc_filter_raw_percent'][3])
+ return ['',orig_join][match_percent >= raw_percent]
+ else: return ''
+
+def caps_matcher(c_caps,c_list):
+ result = False
+ for t in c_list:
+ r = int(t[0] == '*')*2+int(t[-1] == '*')
+ if r == 3 and t[1:-1].lower() in c_caps.lower(): return True
+ elif r == 2 and c_caps.endswith(t[1:]): return True
+ elif r == 1 and c_caps.startswith(t[:-1]): return True
+ elif c_caps == t: return True
+ return result
+
+def iqCB(sess,iq):
+ global timeofset, iq_in, iq_request, last_msg_base, last_msg_time_base, ddos_ignore, ddos_iq, user_hash, server_hash, server_hash_list
+ global disco_excl, message_excl, users_locale
+ iq_in += 1
+ id = iq.getID()
+ if id == None: return None
+ room = unicode(iq.getFrom())
+ if cur_execute_fetchone('select * from bot_owner where jid=%s',(getRoom(room),)): towh = selfjid
+ else: towh = '%s/%s' % (getRoom(room),get_nick_by_jid_res(getRoom(room), selfjid))
+ query = iq.getTag('query')
+ was_request = id in iq_request
+ al,tjid = get_level(getRoom(room),getResourse(room))
+ acclvl = al >= 7 and GT('iq_disco_enable')
+ nnj,tjid = False,getRoom(tjid)
+ if room == selfjid: nnj = True
+ else:
+ for tmp in megabase:
+ if '%s/%s' % tuple(tmp[0:2]) == room:
+ nnj = True
+ break
+
+ c_lang = iq.getAttr('xml:lang')
+ if c_lang: users_locale[room] = c_lang[:2].replace('uk','ua')
+
+ if getServer(Settings['jid']) == room: nnj = True
+
+ if iq.getType()=='error' and was_request:
+ er_name = get_tag(unicode(iq),'error').replace('<','').split()[0]
+ iq_async(id,time.time(),er_name,'error')
+
+ elif iq.getType()=='result' and was_request:
+ try: nspace = query.getNamespace()
+ except: nspace = 'None'
+ if nspace == xmpp.NS_MUC_ADMIN: iq_async(id,nspace,time.time(),iq)
+ elif nspace == xmpp.NS_MUC_OWNER: iq_async(id,nspace,time.time(),iq)
+ elif nspace == xmpp.NS_VERSION:
+ ver_client = unicode(query.getTagData(tag='name'))
+ ver_version = unicode(query.getTagData(tag='version'))
+ ver_os = unicode(query.getTagData(tag='os'))
+ t = cur_execute_fetchone('select jid from versions where room=%s and jid=%s and client=%s and version=%s and os=%s',(getRoom(room),tjid,ver_client,ver_version,ver_os))
+ if not t: cur_execute('insert into versions values (%s,%s,%s,%s,%s,%s)',(getRoom(room),tjid,ver_client,ver_version,ver_os,int(time.time())))
+ iq_async(id,nspace,time.time(),'%s %s // %s' % (ver_client,ver_version,ver_os))
+ elif nspace == xmpp.NS_TIME: iq_async(id,nspace,time.time(),query.getTagData(tag='display'),query.getTagData(tag='utc'),query.getTagData(tag='tz'))
+ elif iq.getTag('time',namespace=xmpp.NS_URN_TIME): iq_async(id,xmpp.NS_URN_TIME,time.time(),iq.getTag('time').getTagData(tag='utc'),iq.getTag('time').getTagData(tag='tzo'))
+ elif iq.getTag('vCard',namespace=xmpp.NS_VCARD): iq_async(id,xmpp.NS_VCARD,time.time(),unicode(iq),iq)
+ else: iq_async(id,nspace,time.time(),unicode(iq),iq)
+
+ elif iq.getType()=='get' and nnj and not ddos_ignore.has_key(tjid):
+ iq_ddos_requests,iq_ddos_limit = GT('ddos_iq_requests'),GT('ddos_iq_limit')
+ nick = getResourse(room)
+ qry = unicode(iq.getTag(name='query'))
+ if ddos_iq.has_key(tjid): time_tuple = [time.time()] + ddos_iq[tjid][:iq_ddos_requests-1]
+ else: time_tuple = [time.time()]
+ ddos_iq[tjid] = time_tuple
+ if len(time_tuple) == iq_ddos_requests and (time_tuple[0]-time_tuple[-1]) < iq_ddos_limit:
+ ddos_ignore[tjid] = [getRoom(room),nick,time.time()+GT('ddos_limit')[al]]
+ pprint('!!! IQ-DDOS Detect: %s %s [%s] %s' % (al, room, tjid, qry),'bright_red')
+ return
+ for t in [tmp[2] for tmp in giq_hook if tmp[1] == 'get']:
+ to_send = t(iq,id,room,acclvl,query,towh,al)
+ if to_send:
+ if to_send != True: sender(to_send)
+ raise xmpp.NodeProcessed
+ elif iq.getType()=='set':
+ for t in [tmp[2] for tmp in giq_hook if tmp[1] == 'set']:
+ to_send = t(iq,id,room,acclvl,query,towh,al)
+ if to_send:
+ if to_send != True: sender(to_send)
+ raise xmpp.NodeProcessed
+
+def iq_async_clean():
+ global iq_reques
+ while not game_over:
+ to = GT('timeout')
+ while to > 0 and not game_over:
+ to -= 1
+ time.sleep(1)
+ if len(iq_request):
+ for tmp in iq_request.keys():
+ if iq_request[tmp][0] + GT('timeout') < time.time(): iq_request.pop(tmp)
+ break
+
+def presence_async_clean():
+ global pres_answer
+ while not game_over:
+ to = GT('timeout')
+ while to > 0 and not game_over:
+ to -= 1
+ time.sleep(1)
+ if len(pres_answer):
+ tm = []
+ for tmp in pres_answer:
+ if tmp[2] + GT('timeout') > time.time(): tm.append(tmp)
+ pres_answer = tm
+
+def iq_async(*answ):
+ global iq_request
+ req = iq_request.pop(answ[0])
+ try: er_code = answ[3]
+ except: er_code = None
+ if er_code == 'error': is_answ = (answ[1]-req[0],(answ[2],'error'))
+ elif req[3] == xmpp.NS_URN_PING or req[3] == answ[1]: is_answ = (answ[2]-req[0],answ[3:])
+ elif req[3] == xmpp.NS_VCARD and answ[1] == 'None':
+ answ[4].setTag('vCard',namespace=xmpp.NS_VCARD)
+ is_answ = (answ[2]-req[0],answ[3:])
+ else:
+ pprint('!!! Got a fake iq answer. Request: %s. Answer: %s. Raw: %s' % (req[3],answ[1],answ[3]),'red')
+ is_answ = (answ[2]-req[0],('%s %s' % (L('Error!'),L('Got a fake iq answer!')),))
+ req[2].append(is_answ)
+ thr(req[1],(tuple(req[2])),'iq_async_%s' % answ[0])
+
+def remove_ignore():
+ global ddos_ignore
+ while not game_over:
+ if len(ddos_ignore):
+ tt = time.time()
+ for tmp in ddos_ignore.keys():
+ if tt > ddos_ignore[tmp][2]:
+ try:
+ ddos_ignore.pop(tmp)
+ pprint('!!! DDOS: Jid %s is removed from ignore!' % tmp,'red')
+ except: pprint('!!! DDOS: Unable find jid %s in ignore list. Perhaps it\'s removed by bot\'s owner!' % tmp,'red')
+ time.sleep(10)
+
+def com_parser(access_mode, nowname, type, room, nick, text, jid):
+ global last_command, ddos_ignore
+ jjid = getRoom(jid)
+ if ddos_ignore.has_key(jjid): return
+ if last_command[1:7] == [nowname, type, room, nick, text, jid] and time.time() < last_command[7]+GT('ddos_diff')[access_mode]:
+ ddos_ignore[jjid] = [room,nick,time.time()+GT('ddos_limit')[access_mode]]
+ pprint('!!! DDOS Detect: %s %s/%s %s %s' % (access_mode, room, nick, jid, text),'bright_red')
+ send_msg(type, room, nick, L('Warning! Exceeded the limit of sending the same commands. You to ignore for %s.','%s/%s'%(room,nick)) % un_unix(GT('ddos_limit')[access_mode],'%s/%s'%(room,nick)))
+ return None
+ no_comm = True
+ cof = cur_execute_fetchall('select * from commonoff;')#!!!
+ for parse in comms:
+ if access_mode >= parse[0] and nick != nowname:
+ not_offed = True
+ if access_mode != 9 or ignore_owner:
+ for co in cof:
+ if co[0]==room and co[1]==text.lower()[:len(co[1])]:
+ not_offed = None
+ break
+ p1l = parse[1].lower()
+ if not_offed and (text.lower() == p1l or text[:len(parse[1])+1].lower() in ['%s '%p1l,'%s\n'%p1l]):
+ pprint('%s %s/%s [%s] %s' % (jid,room,nick,access_mode,text),'bright_cyan')
+ no_comm = None
+ if not parse[3]: thr(parse[2],(type, room, nick, parse[4:]),parse[1])
+ elif parse[3] == 1: thr(parse[2],(type, room, nick),parse[1])
+ elif parse[3] == 2: thr(parse[2],(type, room, nick, text[len(parse[1])+1:]),parse[1])
+ last_command = [access_mode, nowname, type, room, nick, text, jid, time.time()]
+ break
+ return no_comm
+
+def messageCB(sess,mess):
+ global lfrom, lto, lastserver, lastnick, comms, message_in, no_comm, last_hash, current_join
+ message_in += 1
+ type=unicode(mess.getType())
+ room=unicode(mess.getFrom().getStripped())
+ text=unicode(mess.getBody())
+ id = mess.getID()
+ try: was_send = messages_log.pop(id)
+ except: was_send = None
+ if was_send and type == 'error' and mess.getTag('error',attrs={'code':'500','type':'wait'}):
+ time.sleep(time_limit)
+ sender(was_send)
+ return
+
+ if current_join and room in [getRoom(t) for t in current_join.keys()]:
+ try:
+ tt = {}
+ for t in mess.getTag('captcha',attrs={'xmlns':'urn:xmpp:captcha'}).getTag('x',attrs={'xmlns':'jabber:x:data'}).getTags('field'):
+ tt[t.getAttrs()['var']] = t.getTagData('value')
+ if current_join[tt['from']] == tt['sid']:
+ pprint('*** Captcha: %s' % text)
+ current_join[tt['from']] = text
+ else: current_join.pop(tt['from'])
+ except:
+ for t in current_join.keys():
+ if room == getRoom(t):
+ current_join.pop(t)
+ break
+ try:
+ code = mess.getTag('x',namespace=xmpp.NS_MUC_USER).getTagAttr('status','code')
+ if code in msg_status_codes:
+ append_message_to_log(room,'','',type,msg_status_codes[code])
+ return
+ except: pass
+ if (text == 'None' or text == '') and not mess.getSubject(): return
+ if mess.getTimestamp() != None: return
+ nick=mess.getFrom().getResource()
+ if nick != None: nick = unicode(nick)
+ towh=unicode(mess.getTo().getStripped())
+ lprefix = get_local_prefix(room)
+ ft = back_text = text
+ rn = '%s/%s' % (room,nick)
+ access_mode,jid = get_level(room,nick)
+ nowname = get_xnick(room)
+ if '@' not in jid and (jid == 'None' or jid.startswith('j2j.')) and is_owner(room): access_mode = 9
+ if type == 'groupchat' and nick != '' and access_mode >= 0 and jid not in ['None',Settings['jid']]: talk_count(room,jid,nick,text)
+ if nick != '' and nick != None and nick != nowname and len(text)>1 and text != 'None' and text != to_censore(text,room) and access_mode >= 0 and get_config(getRoom(room),'censor'):
+ cens_text = L('Censored!',rn)
+ lvl = get_level(room,nick)[0]
+ if lvl >= 5 and get_config(getRoom(room),'censor_warning'): send_msg(type,room,nick,cens_text)
+ elif lvl == 4 and get_config(getRoom(room),'censor_action_member') != 'off':
+ act = get_config(getRoom(room),'censor_action_member')
+ muc_filter_action(act,jid,room,cens_text)
+ elif lvl < 4 and get_config(getRoom(room),'censor_action_non_member') != 'off':
+ act = get_config(getRoom(room),'censor_action_non_member')
+ muc_filter_action(act,jid,room,cens_text)
+ no_comm = True
+ if text != 'None' and text and access_mode >= 0 and not mess.getSubject():
+ no_comm = True
+ is_par = False
+ if text.startswith('%s: ' % nowname) or text.startswith('%s, ' % nowname):
+ text = text[len(nowname)+2:]
+ is_par = True
+ btext = text
+ if text.startswith(lprefix):
+ text = text[len(lprefix):]
+ is_par = True
+ if type == 'chat': is_par = True
+ if is_par: no_comm = com_parser(access_mode, nowname, type, room, nick, text, jid)
+ if no_comm:
+ btl = btext.lower()
+ if base_type == 'mysql': alias = cur_execute_fetchone("select match ,cmd from alias where (room=%s or room=%s) and ( match =%s or %s like concat( match ,' %%')) order by room desc",(room,'*',btl,btl))
+ else: alias = cur_execute_fetchone("select match ,cmd from alias where (room=%s or room=%s) and ( match =%s or %s ilike match ||' %%') order by room desc",(room,'*',btl,btl))
+ if alias:
+ pprint('%s %s/%s [%s|alias] %s' % (jid,room,nick,access_mode,text),'bright_cyan')
+ argz = btext[len(alias[0])+1:]
+ if not argz:
+ ppr = alias[1].replace('%*', '').replace('%{reduce}*', '').replace('%{reduceall}*', '').replace('%{unused}*', '')
+ ppr = re.sub('\%\{nick2jid\}[0-9\*]','',ppr,flags=re.S|re.I|re.U)
+ cpar = re.findall('%([0-9]+)', ppr, re.S)
+ if len(cpar):
+ for tmp in cpar:
+ try: ppr = ppr.replace('%'+tmp,'')
+ except: pass
+ else:
+ if '%' not in alias[1]: ppr = '%s %%*' % alias[1]
+ else: ppr = alias[1]
+ ppr = ppr.replace('%*', argz).replace('%{reduce}*', argz.strip()).replace('%{reduceall}*', reduce_spaces_all(argz))
+ argz = argz.split()
+ argzbk = list(argz)
+ n2j = re.findall('\%\{nick2jid\}([0-9])',ppr,flags=re.S|re.I|re.U)
+ if n2j:
+ for t in n2j:
+ it = int(t)
+ try: curr_nick = get_jid_by_nick(room, argz[it])
+ except: curr_nick = ''
+ ppr = re.sub('\%%\{nick2jid\}%s' % t,curr_nick,ppr,flags=re.S|re.I|re.U)
+ argzbk = argzbk[:it]+argzbk[it+1:]
+ n2j = re.findall('\%\{nick2jid\}(\*)',ppr,flags=re.S|re.I|re.U)
+ if n2j:
+ curr_nick = get_jid_by_nick(room, ' '.join(argz))
+ ppr = re.sub('\%\{nick2jid\}[0-9\*]',curr_nick,ppr,flags=re.S|re.I|re.U)
+ argz = []
+ if '%' in ppr:
+ cpar = re.findall('%([0-9]+)', ppr, re.S)
+ if cpar:
+ for tmp in cpar:
+ try:
+ it = int(tmp)
+ ppr = ppr.replace('%'+tmp,argz[it])
+ argzbk = argzbk[:it]+argzbk[it+1:]
+ except: pass
+ ppr = ppr.replace('%{unused}*',' '.join(argzbk))
+
+ if len(ppr) == ppr.count(' '): ppr = ''
+ no_comm = com_parser(access_mode, nowname, type, room, nick, ppr, jid)
+
+ thr(msg_afterwork,(mess,room,jid,nick,type,back_text,no_comm,access_mode,nowname),'msg_afterwork')
+
+def msg_afterwork(mess,room,jid,nick,type,back_text,no_comm,access_mode,nowname):
+ global topics
+ not_alowed_flood = False
+ subj = unicode(mess.getSubject())
+ text = back_text
+ if subj != 'None':
+ if '\n' in subj: subj = '\n%s' % subj
+ subj = L('*** Topic: %s','%s/%s'%(room,nick)) % subj
+ if len(text) and text != 'None': subj = text.replace(': ',':\n',1) if '\n' in text else text
+ topics[room],nick = subj,''
+ text = subj
+ not_alowed_flood, no_comm = True, False
+
+ # Fetch and store xhtml images!
+ if type == 'groupchat' and get_config(room,'paste_xhtml_images'):
+ try:
+ raw_data = mess.getTag('html',attrs={'xmlns':'http://jabber.org/protocol/xhtml-im'}).getTag('body').getTagAttr('img','src')
+ ext = re.findall('^data:image/(.*?);',raw_data[:32])[0]
+ def unproc(t): return chr(int(t.group(0)[1:],16))
+ img = re.sub('%[0-9A-F]{2}', unproc, raw_data.split('base64,',1)[1]).decode('base64')
+ filename = '%s.%s' % (hex(int(time.time()))[2:],ext)
+ fp = file(pastepath + filename, 'wb')
+ fp.write(img)
+ fp.close()
+ send_msg(type, room, '', L('Fetched xhtml image: %s%s','%s/%s'%(room,nick)) % (pasteurl,filename))
+ pprint('*** Fetched xhtml image from %s/%s [%s], size %s, file %s' % (room,nick,jid,len(img),pastepath + filename),'cyan')
+ except: pass
+
+ for tmp in gmessage: not_alowed_flood = tmp(room,jid,nick,type,text) or not_alowed_flood
+ if no_comm:
+ for tmp in gactmessage: not_alowed_flood = not_alowed_flood or tmp(room,jid,nick,type,text)
+ if not not_alowed_flood and no_comm and text not in ['None','',' '] and not mess.getSubject():
+ if room != selfjid: is_flood = get_config(getRoom(room),'flood') not in ['off',False]
+ else: is_flood = None
+ if selfjid != jid and access_mode >= 0 and (back_text[:len(nowname)+2] == nowname+': ' or back_text[:len(nowname)+2] == nowname+', ' or type == 'chat') and is_flood:
+ pprint('Send msg human: %s/%s [%s] <<< %s' % (room,nick,type,text),'dark_gray')
+ if len(back_text) > 128: send_msg_human(type, room, nick, L('Too many letters!','%s/%s'%(room,nick)), 'msg_human')
+ else:
+ if back_text[:len(nowname)] == nowname: back_text = back_text[len(nowname)+2:]
+ try:
+ text = getAnswer(type, room, nick, back_text)
+ if text: send_msg_human(type, room, nick, text, 'msg_human')
+ except: pass
+
+def send_msg_human(type, room, nick, text, th):
+ if nick: rn = '%s/%s' % (room,nick)
+ else: rn = room
+ pprint('Send msg human: %s [%s] >>> %s' % (rn,type,text),'dark_gray')
+ thr(send_msg_hmn,(type, room, nick, text),th)
+
+def send_msg_hmn(type, room, nick, text):
+ time.sleep(len(text)/4.0+random.randint(0,3))
+ send_msg(type, room, nick, text)
+
+def to_censore(text,room):
+ ccn = []
+ custom_replace = {}
+ if get_config(getRoom(room),'censor_custom'):
+ custom_censor = get_config(getRoom(room),'censor_custom_rules').replace('\r','').replace('\t','').split('\n')
+ for c in custom_censor:
+ if c.count('#') <= 1: cc=c.split('#',1)
+ else:
+ cc=c.split('#')
+ if cc[-1] == cc[-2] == '': cc = ['#'.join(cc[:-2]),'#']
+ else: cc = ['#'.join(cc[:-1]),cc[-1]]
+ if cc[0]:
+ try:
+ _ = re.compile(cc[0],re.S|re.I|re.U)
+ ccn.append(cc[0])
+ if len(cc) > 1: custom_replace[cc[0]] = reduce_spaces_all(cc[1])
+ except: pass
+ wca = None
+ def_replacer = GT('censor_text')
+ for c in censor+ccn:
+ cn = re.findall(c,' %s ' % text,re.S|re.I|re.U)
+ for tmp in cn:
+ t = ''.join(tmp)
+ try: replacer = custom_replace[c]
+ except: replacer = def_replacer
+ text,wca = text.replace(t,[replacer*len(t),replacer][len(replacer)>1]),True
+ if wca: text = text.strip(' ')
+ return text
+
+def check_hash_actions():
+ global hash_actions_list
+ if hash_actions_list:
+ for tmp in hash_actions_list.keys():
+ if time.time() > hash_actions_list[tmp][1]:
+ hal = hash_actions_list.pop(tmp)
+ if hal[0] == L('whitelist'): put_config(tmp,'muc_filter_whitelist',False)
+ elif hal[0] == L('lock by hash'):
+ hashes_list = reduce_spaces_all(get_config(tmp,'muc_filter_deny_hash_list').replace(',',' ').replace(';',' ').replace('|',' ')).split()
+ if hal[2] in hashes_list:
+ hashes_list.remove(hal[2])
+ put_config(tmp,'muc_filter_deny_hash_list',' '.join(hashes_list))
+ if not hashes_list: put_config(tmp,'muc_filter_deny_hash',False)
+ pprint('Removed hash action %s in %s' % (hal[0],tmp),'cyan')
+
+def presenceCB(sess,mess):
+ global megabase, pres_answer, cu_age, presence_in, hashes, last_hash, users_locale
+ presence_in += 1
+ room=unicode(mess.getFrom().getStripped())
+ nick=unicode(mess.getFrom().getResource())
+ text=unicode(mess.getStatus())
+ type=unicode(mess.getType())
+ affiliation=unicode(mess.getAffiliation())
+ role=unicode(mess.getRole())
+ jid=unicode(mess.getJid())
+ mss = unicode(mess)
+ bad_presence = mss.count('