v2.666
This commit is contained in:
parent
c4e89181c9
commit
23175a5abf
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@ -1,11 +1,8 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"version": "6.6.6",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "maplez",
|
||||
"name": "maple",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/bot_maple.py",
|
||||
|
21
README.md
21
README.md
@ -37,20 +37,19 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdyymMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
## Summary
|
||||
|
||||
```
|
||||
this project is the ( m4plmp - https://git.tcp.direct/decoded/m4pl1mp )
|
||||
except that this one also uses the matrix protocol and talks to
|
||||
matrix and irc servers both. so it's essentialy two clients wrapped
|
||||
in one and not only bridging information between the two networks
|
||||
but unifying maple's services between them as well.
|
||||
this project is a hybrid of hybrids - ( m4pl1mp - https://git.tcp.direct/decoded/m4pl1mp )
|
||||
-
|
||||
this version spans across different networks and not limited to irc, it connects matrix,
|
||||
telegram, discord and offers up a newer way of unifying those services in one core process.
|
||||
|
||||
```
|
||||
---
|
||||
## TODO
|
||||
- plugin wrapper to reduce rewrite the same plugins properties per spanned network
|
||||
- intuitive bridge system
|
||||
- raw tcp socket for external service interfacing
|
||||
- logical color formatting of strings
|
||||
- plugin to monitor version control
|
||||
- plugin to monitor music releases
|
||||
-
|
||||
## Changelog - v2.6
|
||||
- fixed bridge responses double echoing
|
||||
- simplified the calling of some plugins
|
||||
- incorporated a multihead wrapper to keep services running
|
||||
## Changelog - v2.5
|
||||
- telegram/discord/matrix/irc now netspanned ( always more to do )
|
||||
- the routerio logic mostly finished in plugins/tool_bus_plugin.py
|
||||
|
@ -3,11 +3,10 @@ import asyncio
|
||||
import os
|
||||
import threading
|
||||
from time import sleep
|
||||
|
||||
##################################################channel##################################
|
||||
import irc3
|
||||
import torch
|
||||
from nio import AsyncClient, MatrixRoom, RoomMessageText
|
||||
|
||||
##################################################channel##################################
|
||||
from plugins.net_discord_plugin import start_discordbot
|
||||
from plugins.net_irc_plugin import config_ircbot, start_ircbot
|
||||
from plugins.net_matrix_plugin import start_matrixbot
|
||||
@ -15,8 +14,7 @@ from plugins.net_telegram_plugin import start_telegrambot
|
||||
from plugins.tool_bus_plugin import BUS
|
||||
from plugins.tool_dims_plugin import dims
|
||||
from plugins.tool_guds_plugin import guds
|
||||
|
||||
#sfrom plugins.tool_colors_plugin import colorform as print
|
||||
#from plugins.tool_colors_plugin import colorform as print
|
||||
##################################################channel##################################
|
||||
class BOTIO:
|
||||
#######################################################################################
|
||||
@ -31,6 +29,7 @@ class BOTIO:
|
||||
self.net_irc=[]
|
||||
self.net_matrix=[]
|
||||
self.net_discord=[]
|
||||
self.net_discord_initialized=False
|
||||
print(f'<<< ________botio_class >>> [ ircbot configured ]')
|
||||
#######################################################################################
|
||||
def __boot__irc(self):
|
||||
|
0
personalities/default.db
Normal file
0
personalities/default.db
Normal file
@ -65,7 +65,7 @@ class Plugin:
|
||||
self.bot.send(cmd)
|
||||
self.bot.kick(channel, mask.nick, msg)
|
||||
#######################################################################################
|
||||
@command(permission='view', public=True, show_in_help_list=True)
|
||||
@command(permission='view', public=True, show_in_help_list=False)
|
||||
def v(self, mask, target, args):
|
||||
"""Voices all present users in channel
|
||||
%%v
|
||||
@ -144,7 +144,7 @@ class Plugin:
|
||||
def ping(self, mask, target, args):
|
||||
pass
|
||||
#######################################################################################
|
||||
@command(permission='staff', public=True, show_in_help_list=True)
|
||||
@command(permission='staff', public=True, show_in_help_list=False)
|
||||
def staff(self, mask, target, args):
|
||||
"""staff
|
||||
%%staff <noise>...
|
||||
|
@ -9,7 +9,7 @@ from typing import Type
|
||||
import random
|
||||
import string
|
||||
import os,ipdb
|
||||
from plugins.tool_colors_plugin import colorform as print
|
||||
#from plugins.tool_colors_plugin import colorform as print
|
||||
from plugins.tool_dims_plugin import dims
|
||||
########################################################################## THE ASCII LOGO TO BE USED
|
||||
MOTD="""
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||
import asyncio
|
||||
|
||||
import ipdb
|
||||
import irc3
|
||||
from irc3.plugins.command import command
|
||||
|
||||
@ -16,7 +16,7 @@ class Plugin:
|
||||
self.bot = bot
|
||||
#######################################################################################
|
||||
@irc3.extend
|
||||
@command(permission='view')
|
||||
@command(permission='admin',show_in_help_list=False)
|
||||
async def listrooms(self,sender_netroomchan,sender_user,target,):
|
||||
"""listrooms - lists rooms/channels/groups this bot is currently in
|
||||
%%listrooms
|
||||
@ -38,7 +38,7 @@ class Plugin:
|
||||
return results
|
||||
#######################################################################################
|
||||
@irc3.extend
|
||||
@command(permission='Admin')
|
||||
@command(permission='admin',show_in_help_list=False)
|
||||
async def listbridges(self,sender_netroomchan,sender_user,target,):
|
||||
"""listbridges - lists rooms/channels/groups this bot is currently in
|
||||
%%listbridges
|
||||
@ -71,7 +71,7 @@ class Plugin:
|
||||
return results
|
||||
#######################################################################################
|
||||
@irc3.extend
|
||||
@command(permission='view')
|
||||
@command(permission='admin',show_in_help_list=False)
|
||||
async def addbridge(self,mask,target,args):
|
||||
"""addbridge - add a bridge rule for a netspan channel/room/group. use ?listrooms, ?listbridges for information. usage: ?addbridge #b0tsh0p ^χιϛ
|
||||
%%addbridge <noise>...
|
||||
@ -91,7 +91,7 @@ class Plugin:
|
||||
return results
|
||||
#######################################################################################
|
||||
@irc3.extend
|
||||
@command(permission='view')
|
||||
@command(permission='admin',show_in_help_list=False)
|
||||
async def delbridge(self,mask,target,args):
|
||||
"""delbridge - delete a bridge rule for a netspan channel/room/group. use ?listrooms, ?listbridges for information. usage: ?delbridge #b0tsh0p ^χιϛ
|
||||
%%delbridge <noise>...
|
||||
@ -111,7 +111,33 @@ class Plugin:
|
||||
return results
|
||||
#######################################################################################
|
||||
@irc3.extend
|
||||
@command(permission='admin')
|
||||
@command(permission='admin',show_in_help_list=False)
|
||||
async def blackhole(self,mask,target,args):
|
||||
"""blackhole - prevents maple from reverberating on bridges. usage: ?blackhole ?blackhole !asdfasdfasdfsad:pcriot.org add or ?blackhole !asdfasdfasd del
|
||||
%%blackhole <noise>...
|
||||
"""
|
||||
noise=' '.join(args['<noise>']).strip()
|
||||
if noise=="list":
|
||||
self.blackhole=[]
|
||||
ircbot=guds.memory('ircbot')
|
||||
dbname="blackhole"
|
||||
db=ircbot.db.getlist(dbname)
|
||||
if db:
|
||||
for entry in db:
|
||||
self.blackhole.append(entry)
|
||||
return self.blackhole
|
||||
|
||||
src_blackhole=noise.split()[0]
|
||||
command=noise.split()[1]
|
||||
results=[]
|
||||
result=dims.blackholes(src_blackhole,command)
|
||||
results.append(f"[ {src_blackhole} ] - adding blackhole")
|
||||
msg=f'<<< ________dims_plugin >>> [ addblackhole ] - {src_blackhole}'
|
||||
print(msg)
|
||||
return results
|
||||
#######################################################################################
|
||||
@irc3.extend
|
||||
@command(permission='admin',show_in_help_list=False)
|
||||
async def purgebridges(self, mask=None, target=None, data=None, sender_user=None, sender_netroomchan=None, **kw):
|
||||
"""purgebridges - erases channel/room message history across nets
|
||||
%%purgebridges
|
||||
|
@ -27,7 +27,7 @@ class Plugin:
|
||||
return s
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='view')
|
||||
@command(permission='view',show_in_help_list=False)
|
||||
def emote(self, mask, target, args):
|
||||
"""Show Emotion
|
||||
%%emote
|
||||
|
@ -301,9 +301,8 @@ class Plugin:
|
||||
@irc3.event(irc3.rfc.PRIVMSG)
|
||||
def on_privmsg_search_for_maple(self, mask=None, target=None, data=None, **kw):
|
||||
##############################################
|
||||
if mask.nick == 'nickserv':
|
||||
print('returning, message data from bot not user')
|
||||
return
|
||||
if mask.nick.lower()=='nickserv': return
|
||||
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick: return
|
||||
if mask.nick == self.bot.config["nick"]:
|
||||
if data.startswith("["):
|
||||
if not data.find("]")==-1:
|
||||
@ -396,7 +395,7 @@ class Plugin:
|
||||
from plugins.tool_dims_plugin import dims
|
||||
netschanlist=dims.list_channels_bridged(netsrc=net_src)
|
||||
bridgedbus=(BUS(netschanlist))
|
||||
await bridgedbus.input(net_src,[True,net_src,f'{net_user}: {msg}'])
|
||||
await bridgedbus.input(net_src,net_user,msg,True)
|
||||
#######################################################################################
|
||||
def run_chat(self,model,tokenizer,config,mmi_model=None,mmi_tokenizer=None):
|
||||
num_samples=config.getint('decoder','num_samples')
|
||||
@ -500,16 +499,16 @@ class Plugin:
|
||||
self.bot.history.push_maple_messages(maple_message)
|
||||
print(f'maple > {maple_message}')
|
||||
MAPLE_MESSAGE=maple_message.replace('lt 3','<3')
|
||||
msg=f'{USER}: {MAPLE_MESSAGE}'
|
||||
msg=f'{MAPLE_MESSAGE}'
|
||||
from plugins.tool_bus_plugin import BUS
|
||||
from plugins.tool_dims_plugin import dims
|
||||
netschanlist=dims.list_channels_bridged(netsrc=TARGET)
|
||||
netschanlist.append(TARGET)
|
||||
bridgedbus=(BUS(netschanlist))
|
||||
async def truss(self,TARGET,USER,msg):
|
||||
await bridgedbus.input(TARGET,[True,TARGET,f'{USER}: {msg}'])
|
||||
asyncio.run_coroutine_threadsafe( bridgedbus.input(TARGET,[True,TARGET,f'{USER}: {msg}'] ), asyncio.get_event_loop() )
|
||||
# asyncio.run_coroutine_threadsafe(self.truss(TARGET,USER,msg),self.bot.loop)s
|
||||
await bridgedbus.input(TARGET,USER,msg,True)
|
||||
asyncio.run_coroutine_threadsafe( bridgedbus.input(TARGET,USER,msg,True), asyncio.get_event_loop() )
|
||||
# asyncio.run_coroutine_threadsafe(self.truss(TARGET,USER,msg),self.bot.loop)
|
||||
# self.bot.privmsg(TARGET,msg)
|
||||
self.bot.history.loopcount=0
|
||||
return True
|
||||
|
@ -2,7 +2,7 @@
|
||||
import asyncio
|
||||
import os
|
||||
import re
|
||||
|
||||
###########################################################################################
|
||||
import discord
|
||||
from plugins.tool_colors_plugin import colorform as print
|
||||
import ipdb
|
||||
@ -10,11 +10,10 @@ import irc3
|
||||
from discord import Client
|
||||
from discord.ext import commands, tasks
|
||||
from irc3.plugins.command import command
|
||||
|
||||
###########################################################################################
|
||||
from plugins.tool_bus_plugin import BUS
|
||||
from plugins.tool_dims_plugin import dims
|
||||
from plugins.tool_guds_plugin import guds
|
||||
|
||||
###########################################################################################
|
||||
DISCORD__SCHAN=int(os.environ['DISCORD__SCHAN'])
|
||||
DISCORD__DCODE=int(os.environ['DISCORD__DCODE'])
|
||||
@ -26,7 +25,7 @@ global client
|
||||
async def _d_bnc_msg(netsrc,usernick,netdest,data):
|
||||
netsrc="^{}".format(netsrc)
|
||||
bridgedbus=(BUS(netdest))
|
||||
await bridgedbus.input(netsrc,[True,netsrc,f'{usernick}: {data}'])
|
||||
await bridgedbus.input(netsrc,usernick,data,True)
|
||||
# await bridgedbus.output([netsrc,usernick],data)
|
||||
###########################################################################################
|
||||
def d_bnc_msg(netsrc,usernick,netdest,data,):
|
||||
@ -59,6 +58,7 @@ class DISCORDBOT:
|
||||
print(f'<<< _net_discord_plugin >>> [ discordbot connection made as {globals()["DISCORDBOT"].client.user.name} ]')
|
||||
#######################################################################################
|
||||
async def listchannels(self):
|
||||
print(f"<<< _net_discord_plugin >>> [ event: scanning channels ] - started")
|
||||
discordchannels=list(globals()['DISCORDBOT'].client.get_all_channels())
|
||||
if discordchannels[0].__class__.__name__=="CategoryChannel" and discordchannels[0].name=='bridged':
|
||||
for channel in discordchannels[0].channels:
|
||||
@ -111,6 +111,8 @@ class DISCORDBOT:
|
||||
client=discordbot.client
|
||||
if message.author.name == client.user.name:
|
||||
return
|
||||
discordbot=guds.memory('discordbot')
|
||||
asyncio.run_coroutine_threadsafe(discordbot.listchannels(),discordbot.client.loop)
|
||||
channel_name=f"^{message.channel.name}"
|
||||
TARGET="^χιϛ"
|
||||
USER=message.author.name
|
||||
@ -121,7 +123,7 @@ class DISCORDBOT:
|
||||
netschanlist=dims.list_channels_bridged(netsrc=TARGET)
|
||||
netschanlist.append(TARGET)
|
||||
bridgedbus=(BUS(netschanlist))
|
||||
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,[True,TARGET,f'{USER}: {message.content}']),ircbot.loop)
|
||||
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,USER,message.content,True),ircbot.loop)
|
||||
msg=f'<<< _net_discord_plugin >>> [ (d)({message.channel.id})({channel_name}) ] > {str(message.author)}: {message.content}'
|
||||
print(msg)
|
||||
###################################################################################
|
||||
|
142
plugins/net_hydra_plugin.py
Normal file
142
plugins/net_hydra_plugin.py
Normal file
@ -0,0 +1,142 @@
|
||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||
from irc3.plugins.command import command
|
||||
from irc3.plugins.cron import cron
|
||||
from irc3.plugins import core
|
||||
import irc3
|
||||
import os
|
||||
from random import randint as rint
|
||||
from random import shuffle
|
||||
from datetime import datetime
|
||||
###########################################################################################
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
#######################################################################################
|
||||
def __init__(self,bot):
|
||||
self.bot=bot
|
||||
try:
|
||||
self.mode=os.environ['HYDRA_DESIGNATION']
|
||||
self.home=os.environ['HYDRA_HOME']
|
||||
self.enforcing=True
|
||||
else:
|
||||
self.mode="dupe"
|
||||
self.mode=""
|
||||
self.enforcing=False
|
||||
return
|
||||
self.color=""
|
||||
if self.mode=="core": self.color="\x0304"
|
||||
token=""
|
||||
for i in range(7): token+=hex(rint(0,255))[2:].zfill(2).upper()
|
||||
token+=hex(int(datetime.now().timestamp()))[-4:].upper()
|
||||
token=list(token)
|
||||
shuffle(token)
|
||||
self.token=''.join(token)
|
||||
#######################################################################################
|
||||
def server_ready(self):
|
||||
if not self.mode=='core':
|
||||
self.bot.privmsg("maple",f"[hydra:{self.token}] - dupe - connected")
|
||||
else:
|
||||
self.bot.privmsg("maple",f"core - connected")
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.ERR_NICK)
|
||||
def on_errnick(self,srv=None,retcode=None,me=None,nick=None,data=None):
|
||||
###################################################################################
|
||||
if not self.mode=='core': return
|
||||
msg=f'err_nick - srv:{srv} - retcode:{retcode} - me:{me} - nick:{nick} - data:{data}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.NEW_NICK)
|
||||
def on_newnick(self,nick=None,new_nick=None):
|
||||
###################################################################################
|
||||
if not self.mode=='core': return
|
||||
if nick==self.bot.config['nick'] or new_nick==self.bot.config['nick']:
|
||||
msg=f'new_nick - nick:{nick} - new_nick:{new_nick}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.CTCP)
|
||||
def on_ctcp(self,mask=None,event=None,target=None,ctcp=None):
|
||||
###################################################################################
|
||||
if not self.mode=='core': return
|
||||
msg=f'ctcpd - mask:{mask} - event:{event} - target:{target} - ctcp:{ctcp}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.INVITE)
|
||||
def on_invite(self,mask=None,channel=None):
|
||||
###################################################################################
|
||||
if not self.mode=='core': return
|
||||
msg=f'invited - mask:{mask} - channel:{channel}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.KICK)
|
||||
def on_kick(self,mask=None,event=None,channel=None,target=None,data=None):
|
||||
###################################################################################
|
||||
if not self.mode=='core': return
|
||||
msg=f'kicked - mask:{mask} - event:{event} - target:{target} - data:{data}'
|
||||
self.bot.privmsg("maple",msg)
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.PRIVMSG)
|
||||
def on_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
||||
###################################################################################
|
||||
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick: return
|
||||
if mask.nick==self.bot.nick and target==self.bot.config['nick'] and self.mode=='core':
|
||||
if data.endswith('dupe - connected'):
|
||||
_token=data.split("[hydra:")[1].split("]")[0]
|
||||
_nekot=_token[::-1]
|
||||
msg=f'[TOKEN:{_token}] - [NEKOT:{_nekot}] - COLOR:{rint(16,87)}'
|
||||
self.bot.privmsg(self.bot.config['nick'],msg)
|
||||
if mask.nick==self.bot.nick and target==self.bot.config['nick'] and self.mode=='dupe':
|
||||
if not data.find('NEKOT')==-1:
|
||||
_token=data.split(":")[1].split("]")[0]
|
||||
if _token.lower()==self.token.lower():
|
||||
if not data.find("] - [NEKOT:")==-1:
|
||||
_nekot=data.split("] - [NEKOT:")[1].split("]")[0]
|
||||
if _token.lower()==_nekot[::-1].lower():
|
||||
_color=int(data.split(" - COLOR:")[1].strip())
|
||||
if not self.color:
|
||||
self.color=f"\x03{str(_color)}"
|
||||
if self.mode=='core':
|
||||
msg=f"{self.color}[maple:{self.token}] - "
|
||||
else:
|
||||
msg=f"{self.color}[hydra:{self.token}] - "
|
||||
if mask.nick!=self.bot.config['nick']:
|
||||
msg+=f'event:{event} - mask:{mask} - target:{target} - data:'
|
||||
msg+=f'{data}'
|
||||
if kw: msg+=f" - kw:{kw}"
|
||||
self.bot.privmsg(self.home,msg.lower())
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.MY_PRIVMSG)
|
||||
def on_my_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
||||
###################################################################################
|
||||
pass
|
||||
#######################################################################################
|
||||
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
||||
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
||||
target=kw['channel']
|
||||
###################################################################################
|
||||
if mask.nick==self.bot.config['nick']:
|
||||
###############################################################################
|
||||
if kw['event']=='JOIN':
|
||||
self.bot.privmsg("maple",f"joined {target}".lower())
|
||||
if target!=self.home:
|
||||
if enforcing:
|
||||
reason=".[d]."
|
||||
self.bot.part(target,reason)
|
||||
self.bot.privmsg("maple",f"parted {target} - {reason}".lower())
|
||||
if self.mode=="core":
|
||||
msg=f"[maple:{self.token}] - core - maple online"
|
||||
self.bot.privmsg(self.home,msg)
|
||||
else:
|
||||
msg=f"[hydra:{self.token}] - dupe - hydra online"
|
||||
self.bot.privmsg(self.home,msg)
|
||||
if kw['event']=='PART':
|
||||
if self.mode=="core":
|
||||
msg=f"[maple:{self.token}] -"
|
||||
else:
|
||||
msg=f"[hydra:{self.token}] -"
|
||||
self.bot.privmsg("maple",msg+f"parted {target} - {data}")
|
||||
if kw['event']=='QUIT':
|
||||
if self.mode=="core":
|
||||
msg=f"[maple:{self.token}] -"
|
||||
else:
|
||||
msg=f"[hydra:{self.token}] -"
|
||||
self.bot.privmsg("maple",msg+f"quit {target} - {data}")
|
||||
####################################################################################### EOF
|
@ -35,6 +35,7 @@ def config_ircbot():
|
||||
plugins.tool_guds_plugin
|
||||
plugins.tool_bus_plugin
|
||||
plugins.sasl_custom_plugin
|
||||
plugins.net_hydra_plugin
|
||||
plugins.net_irc_plugin
|
||||
plugins.net_matrix_plugin
|
||||
plugins.net_discord_plugin
|
||||
@ -67,10 +68,10 @@ def config_ircbot():
|
||||
plugins.whoami_plugin
|
||||
plugins.joke_plugin
|
||||
plugins.maple_plugin
|
||||
#plugins.openai_plugin
|
||||
|
||||
autojoins =
|
||||
'#b0tsh0p'
|
||||
'#tcpdirect'
|
||||
'#PalletTown'
|
||||
|
||||
flood_burst = 0
|
||||
flood_rate = 1
|
||||
@ -126,10 +127,7 @@ def start_ircbot(self):
|
||||
###################################################################### NET IRC - MAIN [4/4]
|
||||
async def _d_irc_msg(target,msg,) -> None:
|
||||
ircbot=guds.memory('ircbot')
|
||||
await ircbot.privmsg(
|
||||
target,
|
||||
msg,
|
||||
)
|
||||
await ircbot.privmsg(target,msg,)
|
||||
###########################################################################################
|
||||
def d_irc_msg(target,msg,):
|
||||
self=guds.memory('ircbot')
|
||||
@ -161,7 +159,7 @@ class Plugin:
|
||||
if mask.nick.startswith('maple[m]'): return
|
||||
netschanlist=dims.list_channels_bridged(netsrc=target)
|
||||
bridgedbus=(BUS(netschanlist))
|
||||
await bridgedbus.input(target,[True,target,f'{mask.nick}: {data}'])
|
||||
await bridgedbus.input(target,mask.nick,data,True)
|
||||
else: # bot
|
||||
pass
|
||||
#######################################################################################
|
||||
|
@ -70,8 +70,17 @@ class MATRIXBOT:
|
||||
return # ignore messages from self, e.g. @maple:pcriot.org
|
||||
netschanlist=dims.list_channels_bridged(netsrc=room.room_id)
|
||||
bridgedbus=(BUS(netschanlist))
|
||||
await bridgedbus.input(room.room_id,[True,room.room_id,f'{event.sender}: {event.body}'])
|
||||
await bridgedbus.input(room.room_id,event.sender,event.body,True)
|
||||
if not event.body.lower().find("maple")==-1:
|
||||
#######################################################################################
|
||||
self.blackhole=[]
|
||||
ircbot=guds.memory('ircbot')
|
||||
dbname="blackhole"
|
||||
db=ircbot.db.getlist(dbname)
|
||||
if db:
|
||||
for entry in db:
|
||||
self.blackhole.append(entry)
|
||||
if not room.room_id in self.blackhole:
|
||||
ircbot=guds.memory('ircbot')
|
||||
asyncio.run_coroutine_threadsafe(ircbot.indirect_maple([event.sender,room.room_id,"#tcpdirect"],event.body),ircbot.loop)
|
||||
if event.body.startswith("?"):
|
||||
|
@ -50,7 +50,7 @@ class TELEGRAMBOT:
|
||||
#######################################################################################
|
||||
async def _t_bnc_msg(self,netsrc,usernick,netdest,data,):
|
||||
bridgedbus=(BUS(netdest))
|
||||
await bridgedbus.input(f"${netsrc}",[True,usernick,data])
|
||||
await bridgedbus.input(f"${netsrc}",usernick,data,True)
|
||||
###########################################################################################
|
||||
def t_bnc_msg(self,netsrc,usernick,netdest,data,):
|
||||
ircbot=guds.memory('ircbot')
|
||||
@ -91,7 +91,7 @@ class TELEGRAMBOT:
|
||||
netschanlist=dims.list_channels_bridged(netsrc=TARGET)
|
||||
netschanlist.append(TARGET)
|
||||
bridgedbus=(BUS(netschanlist))
|
||||
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,[True,TARGET,f'{USER}: {msg}']),self.ircbot.loop)
|
||||
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,USER,msg,True),self.ircbot.loop)
|
||||
#######################################################################################
|
||||
def error(self,update,context):
|
||||
self.logger.warning('Update "%s" caused error "%s"',update,context.error)
|
||||
|
@ -23,7 +23,7 @@ class Plugin:
|
||||
return self.note(*args)
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='admin', public=True, show_in_help_list=True)
|
||||
@command(permission='admin', public=True, show_in_help_list=False)
|
||||
def note(self, mask, target, args):
|
||||
"""list/write/del notes
|
||||
%%note [<cmd>] [<operation>]
|
||||
@ -44,7 +44,7 @@ class Plugin:
|
||||
return
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='admin', public=True, show_in_help_list=True)
|
||||
@command(permission='admin', public=True, show_in_help_list=False)
|
||||
def note_del(self, mask, target, args):
|
||||
"""Delete Note or * for all notes
|
||||
%%note <cmd> <operation>
|
||||
@ -75,7 +75,7 @@ class Plugin:
|
||||
self.bot.privmsg(target, msg)
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='admin', public=True, show_in_help_list=True)
|
||||
@command(permission='admin', public=True, show_in_help_list=False)
|
||||
def note_list(self, mask, target, args):
|
||||
"""List All Note Names
|
||||
%%note list
|
||||
@ -96,7 +96,7 @@ class Plugin:
|
||||
self.bot.privmsg(target, msg)
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='admin', public=True, show_in_help_list=True)
|
||||
@command(permission='admin', public=True, show_in_help_list=False)
|
||||
def note_read(self, mask, target, args):
|
||||
"""Display Note
|
||||
%%note read <operation>
|
||||
@ -140,7 +140,7 @@ class Plugin:
|
||||
self.bot.privmsg(target, msg)
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='admin', public=True, show_in_help_list=True)
|
||||
@command(permission='admin', public=True, show_in_help_list=False)
|
||||
def note_write(self, mask, target, args):
|
||||
"""Add Note
|
||||
%%note write <note>
|
||||
|
@ -42,6 +42,9 @@ class Plugin:
|
||||
user=noise.split(' ')[0]
|
||||
noise=noise.split(' ')[1:]
|
||||
message=' '.join(noise)
|
||||
if not message:
|
||||
self.quotes(mask,target,{'<nick>': user})
|
||||
return
|
||||
status=''
|
||||
try:
|
||||
quote_list=self.bot.db.getlist("quotes")
|
||||
@ -61,7 +64,7 @@ class Plugin:
|
||||
self.bot.privmsg(target,msg)
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='view')
|
||||
@command(permission='view',show_in_help_list=False)
|
||||
def quotes(self, mask, target, args):
|
||||
"""quotes user
|
||||
%%quotes <nick>
|
||||
|
@ -68,7 +68,7 @@ class BUS:
|
||||
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {data}'
|
||||
print(msg)
|
||||
#######################################################################################
|
||||
async def input(self,network_chanroom_user_src,DATA):
|
||||
async def input(self,network_chanroom_user_src,user_src,data,verbose_bridge):
|
||||
prefix_src=""
|
||||
if network_chanroom_user_src.startswith('!'): prefix_src="m"
|
||||
elif network_chanroom_user_src.startswith('#'): prefix_src="i"
|
||||
@ -82,82 +82,91 @@ class BUS:
|
||||
from plugins.net_discord_plugin import d_discord_msg
|
||||
from plugins.net_telegram_plugin import d_telegram_msg
|
||||
#################################################################### ROUTER
|
||||
brindicator=DATA[0]
|
||||
user_src=f'{DATA[1]}'
|
||||
data=DATA[2]
|
||||
# verbose_bridge=DATA[0]
|
||||
# user_src=f'{DATA[1]}'
|
||||
# data=DATA[2]
|
||||
if type(data)==list:
|
||||
for _data in data:
|
||||
########################################################### TELEGRAM
|
||||
if network_chanroom_dest.startswith('$'):
|
||||
if brindicator:
|
||||
_u,_d=_data.split(":",1)
|
||||
_d=regex.sub("",_d)
|
||||
msg=f'[{_u}{user_src}]{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=_data.split(":",1)
|
||||
_data=regex.sub("",_data)
|
||||
#msg=f'[{_u}{user_src}]{_d}'
|
||||
msg=f'{user_src}: {_data.strip()}'
|
||||
else:
|
||||
msg=regex.sub("",data)
|
||||
d_telegram_msg(network_chanroom_dest,msg)
|
||||
########################################################### DISCORD
|
||||
if network_chanroom_dest.startswith('^'):
|
||||
if brindicator:
|
||||
_u,_d=_data.split(":",1)
|
||||
_d=regex.sub("",_d)
|
||||
msg=f'`[{_u}{user_src}]`{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=_data.split(":",1)
|
||||
_data=regex.sub("",_data)
|
||||
#msg=f'`[{_u}{user_src}]`{_d}'
|
||||
msg=f'{user_src}: {_data.strip()}'
|
||||
else:
|
||||
msg=regex.sub("",data)
|
||||
d_discord_msg(network_chanroom_dest,msg)
|
||||
############################################################ MATRIX
|
||||
if network_chanroom_dest.startswith('!'):
|
||||
if brindicator:
|
||||
_u,_d=_data.split(":",1)
|
||||
_d=regex.sub("",_d)
|
||||
msg=f'[{_u}{user_src}]{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=_data.split(":",1)
|
||||
_data=regex.sub("",_data)
|
||||
#msg=f'[{_u}{user_src}]{_d}'
|
||||
msg=f'{user_src}: {_data.strip()}'
|
||||
else:
|
||||
msg=regex.sub("",data)
|
||||
d_matrix_msg(network_chanroom_dest,msg)
|
||||
############################################################### IRC
|
||||
elif network_chanroom_dest.startswith('#'):
|
||||
if brindicator:
|
||||
_u,_d=_data.split(":",1)
|
||||
msg=f'[{_u}{user_src}]{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=_data.split(":",1)
|
||||
_data=regex.sub("",_data)
|
||||
#msg=f'[{_u}{user_src}]{_d}'
|
||||
msg=f'{user_src}: {_data.strip()}'
|
||||
else:
|
||||
msg=f'{_data}'
|
||||
msg=f'{_data.strip()}'
|
||||
d_irc_msg(network_chanroom_dest,msg)
|
||||
############################################################# LOCAL
|
||||
else:
|
||||
############################################################### TELEGRAM
|
||||
if network_chanroom_dest.startswith('$'):
|
||||
if brindicator:
|
||||
_u,_d=data.split(":",1)
|
||||
_d=regex.sub("",_d)
|
||||
msg=f'[{_u}{user_src}]{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=data.split(":",1)
|
||||
data=regex.sub("",data)
|
||||
#msg=f'[{_u}{user_src}]{_d}'
|
||||
msg=f'{user_src}: {data.strip()}'
|
||||
else:
|
||||
msg=regex.sub("",data)
|
||||
d_telegram_msg(network_chanroom_dest,msg)
|
||||
############################################################### DISCORD
|
||||
if network_chanroom_dest.startswith('^'):
|
||||
if brindicator:
|
||||
_u,_d=data.split(":",1)
|
||||
_d=regex.sub("",_d)
|
||||
msg=f'`[{_u}{user_src}]`{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=data.split(":",1)
|
||||
data=regex.sub("",data)
|
||||
#msg=f'`[{_u}{user_src}]`{_d}'
|
||||
msg=f'{user_src}: {data.strip()}'
|
||||
else:
|
||||
msg=regex.sub("",data)
|
||||
d_discord_msg(network_chanroom_dest,msg)
|
||||
################################################################ MATRIX
|
||||
if network_chanroom_dest.startswith('!'):
|
||||
if brindicator:
|
||||
_u,_d=data.split(":",1)
|
||||
_d=regex.sub("",_d)
|
||||
msg=f'[{_u}{user_src}]{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=data.split(":",1)
|
||||
data=regex.sub("",data)
|
||||
#msg=f'[{_u}{user_src}]{_d}'
|
||||
msg=f'{user_src}: {data.strip()}'
|
||||
else:
|
||||
msg=regex.sub("",data)
|
||||
d_matrix_msg(network_chanroom_dest,msg)
|
||||
################################################################### IRC
|
||||
elif network_chanroom_dest.startswith('#'):
|
||||
if brindicator:
|
||||
_u,_d=data.split(":",1)
|
||||
msg=f'[{_u}{user_src}]{_d}'
|
||||
if verbose_bridge:
|
||||
# _u,_d=data.split(":",1)
|
||||
data=regex.sub("",data)
|
||||
#msg=f'[{_u}{user_src}]{_d}'
|
||||
msg=f'{user_src}: {data.strip()}'
|
||||
else:
|
||||
msg=f'{data}'
|
||||
msg=f'{data.strip()}'
|
||||
d_irc_msg(network_chanroom_dest,msg)
|
||||
################################################################# LOCAL
|
||||
####################################################################################### EOF
|
@ -11,6 +11,7 @@
|
||||
from plugins.tool_guds_plugin import guds
|
||||
import asyncio
|
||||
global dims
|
||||
import ipdb
|
||||
###########################################################################################
|
||||
class DIMS:
|
||||
#######################################################################################
|
||||
@ -338,6 +339,32 @@ class DIMS:
|
||||
# except Exception as e:
|
||||
# return False,e
|
||||
#######################################################################################
|
||||
def blackholes(self,src_blackhole,cmd=None):
|
||||
ipdb.set_trace()
|
||||
self.blackhole=[]
|
||||
ircbot=guds.memory('ircbot')
|
||||
dbname="blackhole"
|
||||
db=ircbot.db.getlist(dbname)
|
||||
if not db:
|
||||
db=[]
|
||||
|
||||
for entry in db:
|
||||
self.blackhole.append(entry)
|
||||
if cmd=="add":
|
||||
try:
|
||||
self.blackhole.append(src_blackhole)
|
||||
ircbot.db.setlist(dbname,self.blackhole)
|
||||
except:
|
||||
pass
|
||||
elif cmd=="del":
|
||||
try:
|
||||
self.blackhole.remove(src_blackhole)
|
||||
ircbot.db.setlist(dbname,self.blackhole)
|
||||
except:
|
||||
pass
|
||||
return self.blackhole
|
||||
|
||||
|
||||
def bridge_routes(self,src_outbound,dest_inbound,cmd=None):
|
||||
err_chan="bot is not in this channel/room/group: {}"
|
||||
err_dupe="this channel/room/group is a duplicate: {}"
|
||||
@ -535,6 +562,7 @@ class DIMS:
|
||||
#######################################################################################
|
||||
def list_channels(self):
|
||||
###################################################################################
|
||||
self.netschanroom=[]
|
||||
ircbot=guds.memory('ircbot')
|
||||
dbname="matrixchat"
|
||||
db=ircbot.db.getlist(dbname)
|
||||
@ -556,8 +584,6 @@ class DIMS:
|
||||
if db:
|
||||
for entry in db:
|
||||
self.netschanroom.append(entry[0])
|
||||
|
||||
|
||||
# for _irc in self.irc:
|
||||
# for _channels in _irc.channels:
|
||||
# self.netschanroom.append(_channels.channel)
|
||||
|
@ -103,7 +103,7 @@ class Plugin:
|
||||
return(search_result)
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
@command(permission='view', public=True, show_in_help_list=True)
|
||||
@command(permission='view', public=True, show_in_help_list=False)
|
||||
def y(self, *args, **kwargs):
|
||||
"""Search for youtube video
|
||||
%%y <keyword>...
|
||||
|
Loading…
Reference in New Issue
Block a user