Handle /me correctly
This commit is contained in:
parent
7da0839dc0
commit
8ae268911a
18
hybridbot.py
18
hybridbot.py
@ -4,6 +4,7 @@
|
||||
import sys
|
||||
sys.path.append('lib')
|
||||
import time
|
||||
import re
|
||||
import sleekxmpp
|
||||
from ircbot import SingleServerIRCBot
|
||||
from ircbot import Channel
|
||||
@ -76,6 +77,16 @@ class IRCBot(SingleServerIRCBot):
|
||||
except:
|
||||
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):
|
||||
def __init__(self, remotejid, chanmuc):
|
||||
@ -127,8 +138,15 @@ class XMPPBot(sleekxmpp.ClientXMPP):
|
||||
mtype='groupchat')
|
||||
|
||||
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)):
|
||||
if not isme:
|
||||
m = '[' + nick + '] ' + text[i]
|
||||
else:
|
||||
m = '***' + nick + ' ' + text[i]
|
||||
|
||||
# Slow down a bit.
|
||||
if i > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user