33 lines
1.6 KiB
Python
33 lines
1.6 KiB
Python
# -*- coding: utf-8 -*- ############################################################################# SOF
|
|
from irc3.plugins.command import command
|
|
from irc3.plugins.cron import cron
|
|
import irc3
|
|
import socket
|
|
#########################################################################################################
|
|
@irc3.plugin
|
|
class Plugin:
|
|
#########################################################################################################
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
#####################################################################################################
|
|
@command(permission='view')
|
|
def tcpac(self, mask, target, args):
|
|
"""tcpac - the irc version of `cat file - | nc tcp.ac 9999`, usage: ?tcpac message
|
|
%%tcpac <message>...
|
|
"""
|
|
msg=' '.join(args['<message>'])
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
s.connect(("tcp.ac", 9999))
|
|
s.sendall(bytes(msg.encode()))
|
|
data = s.recv(1024)
|
|
response=f'{data!r}'
|
|
response=response.replace('\\n',' - ').replace("b'","")[:-1]
|
|
delmsg=s.split(',')[0].split('":"')[1][:-1]
|
|
txtmsg=s.split(',')[1].split('":"')[1][:-2]
|
|
msg=f"{mask.nick}: tcp.ac service - url to share -> txt: {txtmsg}"
|
|
self.bot.privmsg(target,msg)
|
|
msg=f"{mask.nick}: tcp.ac service - url to admin -> del: {delmsg}"
|
|
self.bot.privmsg(mask.nick,msg)
|
|
#####################################################################################################
|
|
##################################################################################################### EOF
|