sed_plugin:ACTION

This commit is contained in:
0xd3d0c3d 2022-07-24 19:31:10 -05:00
parent eb4e8ea786
commit 76edc922ec

View File

@ -3,7 +3,8 @@ import irc3
import os
import random
from string import ascii_lowercase as alpha
SED1_RE = "juggle s/"
import ipdb
SED1_RE = "s/"
SED2_RE = "j/"
###########################################################################################
###########################################################################################
@ -50,6 +51,8 @@ class Plugin:
offset = data.find(SED2_RE)
if offset == 0:
flag=1
else:
flag=1
if flag==0:
self.d.push(data,mask.nick)
return
@ -60,8 +63,6 @@ class Plugin:
try:
_from=_data[1]
_to=_data[2]
if len(_data) == 4:
if _data[3].lower() == 'g': _mode='g'
except Exception as e:
irc_message = f'TCPDIRECT/SED - Error: {e}'
self.bot.privmsg(target, self.bot.emo(irc_message))
@ -76,19 +77,19 @@ class Plugin:
self.d.buffer_text[i] = self.d.buffer_text[i].replace(_from,_to)
break
elif count > 1:
if _mode == 'g':
for y in range(count):
self.d.buffer_text[i] = self.d.buffer_text[i].replace(_from,_to)
break
else:
self.d.buffer_text[i] = self.d.buffer_text[i].replace(_from,_to,1)
break
if count != 0:
self.d.buffer_text[i] = self.d.buffer_text[i].replace(_from,_to,1)
break
if count != 0:
irc_message = "{}: {}".format(self.d.buffer_nick[itwist],self.d.buffer_text[itwist])
else:
irc_message = f"TCPDIRECT/SED - Error: no result for: {data}"
self.bot.privmsg(target, self.bot.emo(irc_message))
if irc_message.find('\x01ACTION'):
nick,msg=irc_message.split(': ')
msg="\x01ACTION "+nick+": "+msg.split('\x01ACTION ')[1]
self.bot.privmsg(target,msg)
else:
self.bot.privmsg(target,self.bot.emo(irc_message))
#######################################################################################
#######################################################################################
###########################################################################################
###########################################################################################
###########################################################################################