29 lines
822 B
Python
29 lines
822 B
Python
![]() |
# -*- coding: utf-8 -*-
|
||
|
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
|
||
|
%%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]
|
||
|
msg=f"{mask.nick}: {response.split()[0]}"
|
||
|
self.bot.privmsg(target,msg)
|
||
|
msg=f"{response}"
|
||
|
self.bot.privmsg(mask.nick,msg)
|