Handle /me correctly
This commit is contained in:
parent
7da0839dc0
commit
8ae268911a
20
hybridbot.py
20
hybridbot.py
@ -4,6 +4,7 @@
|
|||||||
import sys
|
import sys
|
||||||
sys.path.append('lib')
|
sys.path.append('lib')
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
import sleekxmpp
|
import sleekxmpp
|
||||||
from ircbot import SingleServerIRCBot
|
from ircbot import SingleServerIRCBot
|
||||||
from ircbot import Channel
|
from ircbot import Channel
|
||||||
@ -76,6 +77,16 @@ class IRCBot(SingleServerIRCBot):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def on_action(self, c, e):
|
||||||
|
from_nick = nm_to_n(e.source())
|
||||||
|
|
||||||
|
if (from_nick != i_nick):
|
||||||
|
message = '***' + from_nick + ' ' + ''.join(e.arguments())
|
||||||
|
try:
|
||||||
|
inter.xmpp(message)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class XMPPBot(sleekxmpp.ClientXMPP):
|
class XMPPBot(sleekxmpp.ClientXMPP):
|
||||||
def __init__(self, remotejid, chanmuc):
|
def __init__(self, remotejid, chanmuc):
|
||||||
@ -127,8 +138,15 @@ class XMPPBot(sleekxmpp.ClientXMPP):
|
|||||||
mtype='groupchat')
|
mtype='groupchat')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
isme = False
|
||||||
|
if (re.match('^/me .+$', text[0])):
|
||||||
|
text[0] = re.split('^/me ', text[0])[1]
|
||||||
|
isme = True
|
||||||
for i in range(0, len(text)):
|
for i in range(0, len(text)):
|
||||||
m = '[' + nick + '] ' + text[i]
|
if not isme:
|
||||||
|
m = '[' + nick + '] ' + text[i]
|
||||||
|
else:
|
||||||
|
m = '***' + nick + ' ' + text[i]
|
||||||
|
|
||||||
# Slow down a bit.
|
# Slow down a bit.
|
||||||
if i > 0:
|
if i > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user