update
This commit is contained in:
parent
1133bd61e5
commit
845128801b
@ -184,6 +184,8 @@ export HYDRA_HOME=#b0tsh0p
|
|||||||
- openai plugin is written and functions, the setup automation has omitted it's incorporation until baselined
|
- openai plugin is written and functions, the setup automation has omitted it's incorporation until baselined
|
||||||
- convert escaped irc color codes back to terminal codes for ansi_plugin.py
|
- convert escaped irc color codes back to terminal codes for ansi_plugin.py
|
||||||
# [ `CHANGELOG`/`VERSION HISTORY` ]
|
# [ `CHANGELOG`/`VERSION HISTORY` ]
|
||||||
|
# **v2.9**
|
||||||
|
- overhaul - too much to name
|
||||||
# **v2.8**
|
# **v2.8**
|
||||||
- boombox - youtube bug listing spotify.
|
- boombox - youtube bug listing spotify.
|
||||||
- boombox - open.spotify.com url was not pulling page title correctlyl
|
- boombox - open.spotify.com url was not pulling page title correctlyl
|
||||||
|
@ -1,13 +1,40 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
import irc3,re,os,sys,asyncio
|
||||||
|
from datetime import datetime
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
from datetime import datetime
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
import irc3,re,os,asyncio
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
dr1p_home=os.environ['ANSI_HOME']
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
dr1p_home=getenv('ANSI_HOME')
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class EIO():
|
class EIO():
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
self.regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
||||||
self.buffering=False
|
self.buffering=False
|
||||||
@ -16,13 +43,14 @@ class EIO():
|
|||||||
self.cycle=0
|
self.cycle=0
|
||||||
self.sorted=[]
|
self.sorted=[]
|
||||||
self.sorting=[]
|
self.sorting=[]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push(self,nick,channel,dataline,hexdataline):
|
def push(self,nick,channel,dataline,hexdataline):
|
||||||
###################################################################################
|
|
||||||
if self.buffering==False:
|
if self.buffering==False:
|
||||||
self.sorting.append([nick,True,channel,[datetime.now().timestamp()],[dataline],[hexdataline]])
|
self.sorting.append([nick,True,channel,[datetime.now().timestamp()],[dataline],[hexdataline]])
|
||||||
self.buffering=True
|
self.buffering=True
|
||||||
###################################################################################
|
|
||||||
try:
|
try:
|
||||||
for x in self.sorting:
|
for x in self.sorting:
|
||||||
if x[0]==nick:
|
if x[0]==nick:
|
||||||
@ -30,17 +58,25 @@ class EIO():
|
|||||||
x[3].append(datetime.now().timestamp())
|
x[3].append(datetime.now().timestamp())
|
||||||
x[4].append(dataline)
|
x[4].append(dataline)
|
||||||
x[5].append(hexdataline)
|
x[5].append(hexdataline)
|
||||||
###################################################################################
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
self.bot.eio=EIO()
|
self.bot.eio=EIO()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
def on_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
||||||
if mask.nick==self.bot.nick: return
|
if mask.nick==self.bot.nick: return
|
||||||
@ -50,7 +86,10 @@ class Plugin:
|
|||||||
for c in data:
|
for c in data:
|
||||||
hexdataline+=hex(ord(c))[2:].upper()
|
hexdataline+=hex(ord(c))[2:].upper()
|
||||||
self.bot.eio.push(mask.nick,target,data,hexdataline)
|
self.bot.eio.push(mask.nick,target,data,hexdataline)
|
||||||
####################################################################################### EOF
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@cron('* * * * * */1')
|
@cron('* * * * * */1')
|
||||||
def eio_cron(bot):
|
def eio_cron(bot):
|
||||||
eio=bot.eio
|
eio=bot.eio
|
||||||
@ -80,21 +119,27 @@ def eio_cron(bot):
|
|||||||
eio_sorted=eio.sorted[-1]
|
eio_sorted=eio.sorted[-1]
|
||||||
for dataline in eio_sorted[2]:
|
for dataline in eio_sorted[2]:
|
||||||
bot.privmsg(dr1p_home,dataline)
|
bot.privmsg(dr1p_home,dataline)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
SELF_DISABLE_FLAG=True
|
SELF_DISABLE_FLAG=True
|
||||||
try:
|
try:
|
||||||
for eio_sorting in eio.sorting:
|
for eio_sorting in eio.sorting:
|
||||||
for isnotdisabled in eio_sorting[1]:
|
for isnotdisabled in eio_sorting[1]:
|
||||||
if isnotdisabled: SELF_DISABLE_FLAG=False
|
if isnotdisabled: SELF_DISABLE_FLAG=False
|
||||||
###################################################################################
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if SELF_DISABLE_FLAG:
|
if SELF_DISABLE_FLAG:
|
||||||
msg=f'<<< ________ansi_plugin >>> [ event: control code buffer ]'
|
msg=f'<<< ________ansi_plugin >>> [ event: control code buffer ]'
|
||||||
msg+=' - '
|
msg+=' - '
|
||||||
msg+='finished, disabling cleanup cronjob'
|
msg+='finished, disabling cleanup cronjob'
|
||||||
print(msg)
|
print(msg)
|
||||||
bot.eio.buffering=False
|
bot.eio.buffering=False
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,31 +1,58 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
import irc3, os
|
import irc3, os, sys
|
||||||
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
NICKSERV_USERNAME=os.environ['NICKSERV_USERNAME']
|
|
||||||
NICKSERV_PASSWORD=os.environ['NICKSERV_PASSWORD']
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
NICKSERV_USERNAME=getenv('NICKSERV_USERNAME')
|
||||||
|
NICKSERV_PASSWORD=getenv('NICKSERV_PASSWORD')
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.CONNECTED)
|
@irc3.event(irc3.rfc.CONNECTED)
|
||||||
def connected(self, **kw):
|
def connected(self, **kw):
|
||||||
MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}"
|
MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}"
|
||||||
self.bot.privmsg('NICKSERV',MSG)
|
self.bot.privmsg('NICKSERV',MSG)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@cron('*/1 * * * *')
|
@cron('*/1 * * * *')
|
||||||
def cron_auth(bot):
|
def cron_auth(bot):
|
||||||
if not bot.nick==bot.original_nick:
|
if not bot.nick==bot.original_nick:
|
||||||
MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}"
|
MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}"
|
||||||
bot.privmsg('NICKSERV',MSG)
|
bot.privmsg('NICKSERV',MSG)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.utils import IrcString
|
from irc3.utils import IrcString
|
||||||
import irc3
|
import irc3
|
||||||
@ -10,12 +12,21 @@ import functools
|
|||||||
from random import shuffle
|
from random import shuffle
|
||||||
import string
|
import string
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
USER_STRING_MATCH = re.compile('(.+)!(.+)@(.+)')
|
USER_STRING_MATCH = re.compile('(.+)!(.+)@(.+)')
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
staff_set=set()
|
staff_set=set()
|
||||||
@ -34,7 +45,10 @@ class Plugin:
|
|||||||
for hostname in self.bot.staff_list:
|
for hostname in self.bot.staff_list:
|
||||||
if not current_masks.get(hostname):
|
if not current_masks.get(hostname):
|
||||||
self.bot.config['irc3.plugins.command.masks'][hostname] = "staff"
|
self.bot.config['irc3.plugins.command.masks'][hostname] = "staff"
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def check_if_ignored(self, hostmask):
|
def check_if_ignored(self, hostmask):
|
||||||
global_hostmask = hostmask.replace(hostmask.nick, ".+")
|
global_hostmask = hostmask.replace(hostmask.nick, ".+")
|
||||||
@ -47,19 +61,10 @@ class Plugin:
|
|||||||
if nick_pattern.match(mask):
|
if nick_pattern.match(mask):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
@irc3.event(irc3.rfc.CONNECTED)
|
|
||||||
def _add_hostmask(self, *args, **kwargs):
|
|
||||||
def handle_who(self, response):
|
|
||||||
result = response.result()
|
|
||||||
self.bot.hostmask = result.get('mask')
|
|
||||||
task = self.bot.who(self.bot.get_nick())
|
|
||||||
task.add_done_callback(functools.partial(handle_who, self))
|
|
||||||
opper_password = self.bot.config.get("opper_password")
|
|
||||||
opper_username = self.bot.config.get("opper_username")
|
|
||||||
self.bot.send_line(f"GOD {opper_username} {opper_password}")
|
|
||||||
self.bot.privmsg("nickserv", f"IDENTIFY {self.bot.nick} {opper_password}")
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.JOIN)
|
@irc3.event(irc3.rfc.JOIN)
|
||||||
def auto_kick_handler(self, mask, channel, **kw):
|
def auto_kick_handler(self, mask, channel, **kw):
|
||||||
msg = "g1mp'n ain't easy unless you're maple"
|
msg = "g1mp'n ain't easy unless you're maple"
|
||||||
@ -67,30 +72,41 @@ class Plugin:
|
|||||||
cmd = f"MODE {channel} +b {mask.nick}!*@*"
|
cmd = f"MODE {channel} +b {mask.nick}!*@*"
|
||||||
self.bot.send(cmd)
|
self.bot.send(cmd)
|
||||||
self.bot.kick(channel, mask.nick, msg)
|
self.bot.kick(channel, mask.nick, msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mdeban(self, mask, target, args):
|
def mdeban(self, mask, target, args):
|
||||||
"""removes all present bans from channel
|
"""removes all present bans from channel
|
||||||
%%mdeban
|
%%mdeban
|
||||||
"""
|
"""
|
||||||
self.target=target
|
self.target=target
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def handle_bans(self, response):
|
def handle_bans(self, response):
|
||||||
result = response.result()
|
result = response.result()
|
||||||
[ self.bot.send(f'MODE {self.target} -b {x["mask"]}') for x in result['bans'] ]
|
[ self.bot.send(f'MODE {self.target} -b {x["mask"]}') for x in result['bans'] ]
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
task = self.bot.channel_bans(self.target)
|
task = self.bot.channel_bans(self.target)
|
||||||
task.add_done_callback(functools.partial(handle_bans, self))
|
task.add_done_callback(functools.partial(handle_bans, self))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def lockdown(self, mask, target, args):
|
def lockdown(self, mask, target, args):
|
||||||
"""lockdown channel
|
"""lockdown channel
|
||||||
%%lockdown
|
%%lockdown
|
||||||
"""
|
"""
|
||||||
###############################################################################
|
|
||||||
try:
|
try:
|
||||||
yek=list(string.ascii_letters+string.digits)
|
yek=list(string.ascii_letters+string.digits)
|
||||||
shuffle(yek)
|
shuffle(yek)
|
||||||
@ -98,13 +114,15 @@ class Plugin:
|
|||||||
self.mv(mask,target,args)
|
self.mv(mask,target,args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def unlockdown(self, mask, target, args):
|
def unlockdown(self, mask, target, args):
|
||||||
"""unlockdown channel
|
"""unlockdown channel
|
||||||
%%unlockdown
|
%%unlockdown
|
||||||
"""
|
"""
|
||||||
###############################################################################
|
|
||||||
try:
|
try:
|
||||||
self.bot.send(f'MODE {target} -mik')
|
self.bot.send(f'MODE {target} -mik')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -117,48 +135,68 @@ class Plugin:
|
|||||||
"""
|
"""
|
||||||
channel=args.get('<channel>')
|
channel=args.get('<channel>')
|
||||||
hostmask=args.get('<hostmask>')
|
hostmask=args.get('<hostmask>')
|
||||||
###############################################################################
|
|
||||||
try:
|
try:
|
||||||
self.bot.send(f'MODE {channel} -b {hostmask}')
|
self.bot.send(f'MODE {channel} -b {hostmask}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def ban(self, mask, target, args):
|
def ban(self, mask, target, args):
|
||||||
"""bans user from channel
|
"""bans user from channel
|
||||||
%%ban <nick>
|
%%ban <nick>
|
||||||
"""
|
"""
|
||||||
self.target=target
|
self.target=target
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def handle_who(self, response):
|
def handle_who(self, response):
|
||||||
result = response.result()
|
result = response.result()
|
||||||
self.bot.send(f"MODE {self.target} +b *!{result['user']}@*")
|
self.bot.send(f"MODE {self.target} +b *!{result['user']}@*")
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
USER=args['<nick>']
|
USER=args['<nick>']
|
||||||
task = self.bot.who(USER)
|
task = self.bot.who(USER)
|
||||||
task.add_done_callback(functools.partial(handle_who, self))
|
task.add_done_callback(functools.partial(handle_who, self))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mban(self, mask, target, args):
|
def mban(self, mask, target, args):
|
||||||
"""Bans all present users from channel
|
"""Bans all present users from channel
|
||||||
%%mban
|
%%mban
|
||||||
"""
|
"""
|
||||||
self.target=target
|
self.target=target
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def handle_who(self, response):
|
def handle_who(self, response):
|
||||||
result = response.result()
|
result = response.result()
|
||||||
self.bot.send(f"MODE {self.target} +b *!{result['user']}@*")
|
self.bot.send(f"MODE {self.target} +b *!{result['user']}@*")
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for USER in self.bot.channels[target]:
|
for USER in self.bot.channels[target]:
|
||||||
task = self.bot.who(USER)
|
task = self.bot.who(USER)
|
||||||
task.add_done_callback(functools.partial(handle_who, self))
|
task.add_done_callback(functools.partial(handle_who, self))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mkick(self, mask, target, args):
|
def mkick(self, mask, target, args):
|
||||||
"""Kicks all present users from channel
|
"""Kicks all present users from channel
|
||||||
@ -169,7 +207,10 @@ class Plugin:
|
|||||||
[self.bot.kick(target,x,self.bot.emo(msg)) for x in self.bot.channels[target]]
|
[self.bot.kick(target,x,self.bot.emo(msg)) for x in self.bot.channels[target]]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def kick(self, mask, target, args):
|
def kick(self, mask, target, args):
|
||||||
"""Kicks user from channel
|
"""Kicks user from channel
|
||||||
@ -181,7 +222,10 @@ class Plugin:
|
|||||||
self.bot.kick(target,nick,self.bot.emo(msg))
|
self.bot.kick(target,nick,self.bot.emo(msg))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mv(self, mask, target, args):
|
def mv(self, mask, target, args):
|
||||||
"""Voices all present users in channel
|
"""Voices all present users in channel
|
||||||
@ -191,7 +235,10 @@ class Plugin:
|
|||||||
[ self.bot.send(f'MODE {target} +v {x}') for x in self.bot.channels[target]]
|
[ self.bot.send(f'MODE {target} +v {x}') for x in self.bot.channels[target]]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mdv(self, mask, target, args):
|
def mdv(self, mask, target, args):
|
||||||
"""DeVoices all present users in channel
|
"""DeVoices all present users in channel
|
||||||
@ -201,7 +248,10 @@ class Plugin:
|
|||||||
[ self.bot.send(f'MODE {target} -v {x}') for x in self.bot.channels[target]]
|
[ self.bot.send(f'MODE {target} -v {x}') for x in self.bot.channels[target]]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def v(self, mask, target, args):
|
def v(self, mask, target, args):
|
||||||
"""Voices user in channel
|
"""Voices user in channel
|
||||||
@ -212,7 +262,10 @@ class Plugin:
|
|||||||
self.bot.send(f'MODE {target} +v {nick}')
|
self.bot.send(f'MODE {target} +v {nick}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def dv(self, mask, target, args):
|
def dv(self, mask, target, args):
|
||||||
"""DeVoices user in channel
|
"""DeVoices user in channel
|
||||||
@ -223,7 +276,10 @@ class Plugin:
|
|||||||
self.bot.send(f'MODE {target} -v {nick}')
|
self.bot.send(f'MODE {target} -v {nick}')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mop(self, mask, target, args):
|
def mop(self, mask, target, args):
|
||||||
"""Ops all present users in channel
|
"""Ops all present users in channel
|
||||||
@ -233,7 +289,10 @@ class Plugin:
|
|||||||
[ self.bot.send(f'MODE {target} +o {x}') for x in self.bot.channels[target]]
|
[ self.bot.send(f'MODE {target} +o {x}') for x in self.bot.channels[target]]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mdeop(self, mask, target, args):
|
def mdeop(self, mask, target, args):
|
||||||
"""DeOps all present users in channel
|
"""DeOps all present users in channel
|
||||||
@ -243,7 +302,10 @@ class Plugin:
|
|||||||
[ self.bot.send(f'MODE {target} -o {x}') for x in self.bot.channels[target]]
|
[ self.bot.send(f'MODE {target} -o {x}') for x in self.bot.channels[target]]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def op(self, mask, target, args):
|
def op(self, mask, target, args):
|
||||||
"""Ops user
|
"""Ops user
|
||||||
@ -254,7 +316,10 @@ class Plugin:
|
|||||||
self.bot.send(f'MODE {target} +o {nick}')
|
self.bot.send(f'MODE {target} +o {nick}')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def deop(self, mask, target, args):
|
def deop(self, mask, target, args):
|
||||||
"""Deops user
|
"""Deops user
|
||||||
@ -265,7 +330,10 @@ class Plugin:
|
|||||||
self.bot.send(f'MODE {target} -o {nick}')
|
self.bot.send(f'MODE {target} -o {nick}')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mhop(self, mask, target, args):
|
def mhop(self, mask, target, args):
|
||||||
"""Hops all present users in channel
|
"""Hops all present users in channel
|
||||||
@ -275,7 +343,10 @@ class Plugin:
|
|||||||
[ self.bot.send(f'MODE {target} +h {x}') for x in self.bot.channels[target]]
|
[ self.bot.send(f'MODE {target} +h {x}') for x in self.bot.channels[target]]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def mdehop(self, mask, target, args):
|
def mdehop(self, mask, target, args):
|
||||||
"""DeHops all present users in channel
|
"""DeHops all present users in channel
|
||||||
@ -285,7 +356,10 @@ class Plugin:
|
|||||||
[ self.bot.send(f'MODE {target} -h {x}') for x in self.bot.channels[target]]
|
[ self.bot.send(f'MODE {target} -h {x}') for x in self.bot.channels[target]]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def hop(self, mask, target, args):
|
def hop(self, mask, target, args):
|
||||||
"""Hops user
|
"""Hops user
|
||||||
@ -296,7 +370,10 @@ class Plugin:
|
|||||||
self.bot.send(f'MODE {target} +h {nick}')
|
self.bot.send(f'MODE {target} +h {nick}')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def dehop(self, mask, target, args):
|
def dehop(self, mask, target, args):
|
||||||
"""Dehops user
|
"""Dehops user
|
||||||
@ -307,7 +384,10 @@ class Plugin:
|
|||||||
self.bot.send(f'MODE {target} -h {nick}')
|
self.bot.send(f'MODE {target} -h {nick}')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission="admin", show_in_help_list=False)
|
@command(permission="admin", show_in_help_list=False)
|
||||||
def stats(self, mask, target, args):
|
def stats(self, mask, target, args):
|
||||||
"""Stats
|
"""Stats
|
||||||
@ -320,37 +400,61 @@ class Plugin:
|
|||||||
for mode, nicknames in sorted(channel.modes.items()):
|
for mode, nicknames in sorted(channel.modes.items()):
|
||||||
message += f' - {mode}({len(nicknames)})'
|
message += f' - {mode}({len(nicknames)})'
|
||||||
self.bot.privmsg(target, message)
|
self.bot.privmsg(target, message)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
#######################################################################################
|
||||||
def restart(self, mask, target, args):
|
|
||||||
"""restart
|
@command(permission='admin', show_in_help_list=False)
|
||||||
%%restart
|
def reload(self, mask, target, args):
|
||||||
|
"""reload
|
||||||
|
%%reload <noise>
|
||||||
"""
|
"""
|
||||||
self.bot.privmsg(target, 'BOT RESTARTING')
|
noise = f"plugins.{args.get('<noise>')}_plugin"
|
||||||
time.sleep(1)
|
self.bot.privmsg(target, f'reloading plugin: {noise}')
|
||||||
os.execl(sys.executable, sys.executable, *sys.argv)
|
try:
|
||||||
|
self.bot.reload(noise)
|
||||||
|
except:
|
||||||
|
self.bot.privmsg(target, f'error: reloading plugin: {noise} failed')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
def uptime(self, mask, target, args):
|
def uptime(self, mask, target, args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
def ping(self, mask, target, args):
|
def ping(self, mask, target, args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='staff', public=True, show_in_help_list=False)
|
@command(permission='staff', public=True, show_in_help_list=False)
|
||||||
def staff(self, mask, target, args):
|
def staff(self, mask, target, args):
|
||||||
"""staff
|
"""staff
|
||||||
%%staff <noise>...
|
%%staff <noise>...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __staff_list(self, mask, target, args):
|
def __staff_list(self, mask, target, args):
|
||||||
current_masks = self.bot.config.get("irc3.plugins.command.masks", "")
|
current_masks = self.bot.config.get("irc3.plugins.command.masks", "")
|
||||||
current_staff_list = [k for k,v in current_masks.items() if v in ["all_permissions", "staff"]]
|
current_staff_list = [k for k,v in current_masks.items() if v in ["all_permissions", "staff"]]
|
||||||
self.bot.privmsg(target, "\x02༺Staff List༻\x0F\x02\x0303 > \x0F\x0302{}".format(", ".join(current_staff_list)))
|
self.bot.privmsg(target, "\x02༺Staff List༻\x0F\x02\x0303 > \x0F\x0302{}".format(", ".join(current_staff_list)))
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __staff_del(self, mask, target, args):
|
def __staff_del(self, mask, target, args):
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def del_hostmask(self, host_string):
|
def del_hostmask(self, host_string):
|
||||||
current_masks = self.bot.config.get("irc3.plugins.command.masks", "")
|
current_masks = self.bot.config.get("irc3.plugins.command.masks", "")
|
||||||
if host_string in current_masks.keys():
|
if host_string in current_masks.keys():
|
||||||
@ -368,14 +472,20 @@ class Plugin:
|
|||||||
pass # pass for brevarity
|
pass # pass for brevarity
|
||||||
else:
|
else:
|
||||||
self.bot.privmsg(target, f'{host_string} is not a staff member')
|
self.bot.privmsg(target, f'{host_string} is not a staff member')
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def handle_who(self, response):
|
def handle_who(self, response):
|
||||||
result = response.result()
|
result = response.result()
|
||||||
nick = result.get("nick")
|
nick = result.get("nick")
|
||||||
mask = result.get('mask')
|
mask = result.get('mask')
|
||||||
host_string = mask.replace(nick,"*")
|
host_string = mask.replace(nick,"*")
|
||||||
del_hostmask(self, host_string)
|
del_hostmask(self, host_string)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
nick = args.get("<nick>")
|
nick = args.get("<nick>")
|
||||||
match_list = USER_STRING_MATCH.findall(nick)
|
match_list = USER_STRING_MATCH.findall(nick)
|
||||||
if match_list and len(match_list[0]) == 3:
|
if match_list and len(match_list[0]) == 3:
|
||||||
@ -385,9 +495,15 @@ class Plugin:
|
|||||||
task = self.bot.who(nick)
|
task = self.bot.who(nick)
|
||||||
task.add_done_callback(functools.partial(handle_who, self))
|
task.add_done_callback(functools.partial(handle_who, self))
|
||||||
return
|
return
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __staff_add(self, mask, target, args):
|
def __staff_add(self, mask, target, args):
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def add_hostmask(self, host_string):
|
def add_hostmask(self, host_string):
|
||||||
current_masks = self.bot.config.get("irc3.plugins.command.masks", "")
|
current_masks = self.bot.config.get("irc3.plugins.command.masks", "")
|
||||||
if host_string in current_masks.keys():
|
if host_string in current_masks.keys():
|
||||||
@ -400,17 +516,26 @@ class Plugin:
|
|||||||
self.bot.staff_list.add(host_string)
|
self.bot.staff_list.add(host_string)
|
||||||
self.bot.db.setlist("staff_list", self.bot.staff_list)
|
self.bot.db.setlist("staff_list", self.bot.staff_list)
|
||||||
self.bot.privmsg(target, f'{host_string} added to staff')
|
self.bot.privmsg(target, f'{host_string} added to staff')
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def handle_who(self, response):
|
def handle_who(self, response):
|
||||||
result = response.result()
|
result = response.result()
|
||||||
nick = result.get("nick")
|
nick = result.get("nick")
|
||||||
mask = result.get('mask')
|
mask = result.get('mask')
|
||||||
host_string = mask.replace(nick,"*")
|
host_string = mask.replace(nick,"*")
|
||||||
add_hostmask(self, host_string)
|
add_hostmask(self, host_string)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
nick = args.get("<nick>")
|
nick = args.get("<nick>")
|
||||||
match_list = USER_STRING_MATCH.findall(nick)
|
match_list = USER_STRING_MATCH.findall(nick)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
if match_list and len(match_list[0]) == 3:
|
if match_list and len(match_list[0]) == 3:
|
||||||
add_hostmask(self, nick)
|
add_hostmask(self, nick)
|
||||||
return
|
return
|
||||||
@ -418,10 +543,16 @@ class Plugin:
|
|||||||
task = self.bot.who(nick)
|
task = self.bot.who(nick)
|
||||||
task.add_done_callback(functools.partial(handle_who, self))
|
task.add_done_callback(functools.partial(handle_who, self))
|
||||||
return
|
return
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
cmd = ' '.join(args['<noise>'])[0]
|
cmd = ' '.join(args['<noise>'])[0]
|
||||||
args = ' '.join(args['<noise>'])[1:]
|
args = ' '.join(args['<noise>'])[1:]
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if not cmd:
|
if not cmd:
|
||||||
self.bot.privmsg(target, "please specify add/del/list")
|
self.bot.privmsg(target, "please specify add/del/list")
|
||||||
elif cmd in ["d","del","delete","remove"]:
|
elif cmd in ["d","del","delete","remove"]:
|
||||||
@ -430,5 +561,6 @@ class Plugin:
|
|||||||
__staff_list(self, mask, target, args)
|
__staff_list(self, mask, target, args)
|
||||||
elif cmd in ["w", "write","a", "add"]:
|
elif cmd in ["w", "write","a", "add"]:
|
||||||
__staff_add(self, mask, target, args)
|
__staff_add(self, mask, target, args)
|
||||||
###################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
@ -1,8 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???YOUTUBE???
|
???YOUTUBE???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -12,42 +17,94 @@ import random
|
|||||||
import string
|
import string
|
||||||
import os
|
import os
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
########################################################################## THE ASCII LOGO TO BE USED
|
|
||||||
|
################################################################# THE ASCII LOGO TO BE USED
|
||||||
|
################################################################# THE ASCII LOGO TO BE USED
|
||||||
|
|
||||||
MOTD="""
|
MOTD="""
|
||||||
_________ _________ _________ ___ ___ _________ _________ ____ ____
|
_________ _________ _________ ___ ___ _________ _________ ____ ____
|
||||||
| o ) / O \ / O \ | \ / | | o ) / O \ \ \_/ /
|
| o ) / O \ / O \ | \ / | | o ) / O \ \ \_/ /
|
||||||
|_____O___) \_________/ \_________/ |____|____| |_____O___) \_________/ /___/%\___\\
|
|_____O___) \_________/ \_________/ |____|____| |_____O___) \_________/ /___/%\___\\
|
||||||
'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BB' 'BB'
|
'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BBBBBBB' 'BB' 'BB'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
######################################################################## BOOMBOX MAIN ENTRY
|
######################################################################## BOOMBOX MAIN ENTRY
|
||||||
|
######################################################################## BOOMBOX MAIN ENTRY
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
##################################################################### BOOMBOX MAIN INIT
|
##################################################################### BOOMBOX MAIN INIT
|
||||||
|
##################################################################### BOOMBOX MAIN INIT
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
self.bot.diagnostic_flag=False
|
self.bot.diagnostic_flag=False
|
||||||
|
self.bot.ceiling__last_songs=50
|
||||||
self.bot.bbs=BOOMBOX_CONFIG(self.bot)
|
self.bot.bbs=BOOMBOX_CONFIG(self.bot)
|
||||||
|
|
||||||
#################################################################### SOF COLOR INIT
|
#################################################################### SOF COLOR INIT
|
||||||
|
#################################################################### SOF COLOR INIT
|
||||||
|
|
||||||
self.bot.bbs.c=[]
|
self.bot.bbs.c=[]
|
||||||
self.bot.bbs.b1,self.bot.bbs.b2,self.bot.bbs.b3,self.bot.bbs.b4=self.bot.bbs.palette()[0:4]
|
self.bot.bbs.b1,self.bot.bbs.b2,self.bot.bbs.b3,self.bot.bbs.b4=self.bot.bbs.palette()[0:4]
|
||||||
self.bot.bbs.b5,self.bot.bbs.b6,self.bot.bbs.b7,self.bot.bbs.b8=self.bot.bbs.palette()[0:4]
|
self.bot.bbs.b5,self.bot.bbs.b6,self.bot.bbs.b7,self.bot.bbs.b8=self.bot.bbs.palette()[0:4]
|
||||||
|
|
||||||
######################################################################## COLOR INIT
|
######################################################################## COLOR INIT
|
||||||
|
######################################################################## COLOR INIT
|
||||||
|
|
||||||
self.bot.bbs.sites=['soundcloud''spotify','bandcamp']
|
self.bot.bbs.sites=['soundcloud''spotify','bandcamp']
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
self.bot.bbs.sites.append('youtube')
|
self.bot.bbs.sites.append('youtube')
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
self.bot.bbs.floor__top_songs=15
|
self.bot.bbs.floor__top_songs=15
|
||||||
self.bot.bbs.floor__last_songs=15
|
self.bot.bbs.floor__last_songs=15
|
||||||
self.bot.bbs.floor__top_users=5
|
self.bot.bbs.floor__top_users=5
|
||||||
self.bot.bbs.floor__top_sites=len(self.bot.bbs.sites)
|
self.bot.bbs.floor__top_sites=len(self.bot.bbs.sites)
|
||||||
self.bot.bbs.ceiling__top_songs=50
|
self.bot.bbs.ceiling__top_songs=50
|
||||||
self.bot.bbs.ceiling__last_songs=50
|
self.bot.bbs.ceiling__last_songs=self.bot.ceiling__last_songs
|
||||||
|
del(self.bot.ceiling__last_songs)
|
||||||
self.bot.bbs.ceiling__top_users=25
|
self.bot.bbs.ceiling__top_users=25
|
||||||
self.bot.bbs.ceiling__top_sites=len(self.bot.bbs.sites)
|
self.bot.bbs.ceiling__top_sites=len(self.bot.bbs.sites)
|
||||||
|
|
||||||
#################################################################### EOF COLOR INIT
|
#################################################################### EOF COLOR INIT
|
||||||
|
#################################################################### EOF COLOR INIT
|
||||||
|
|
||||||
self.bot.bbs.bot=self.bot
|
self.bot.bbs.bot=self.bot
|
||||||
################################################################## CHECK OR PREP DB
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def reload(cls, old):
|
||||||
|
return cls(old.bot)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def before_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def after_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
######################################################################## BOOMBOX MAIN 1
|
######################################################################## BOOMBOX MAIN 1
|
||||||
|
######################################################################## BOOMBOX MAIN 1
|
||||||
|
|
||||||
@command(permission='view',public=True, show_in_help_list=False)
|
@command(permission='view',public=True, show_in_help_list=False)
|
||||||
def dbdo(self, mask, target, args):
|
def dbdo(self, mask, target, args):
|
||||||
"""dbdo sync
|
"""dbdo sync
|
||||||
@ -59,7 +116,10 @@ class Plugin:
|
|||||||
op=noise.split()[1]
|
op=noise.split()[1]
|
||||||
data=' '.join(noise.split()[2:])
|
data=' '.join(noise.split()[2:])
|
||||||
result=self.bot.bbs.dbdo(db,op,data)
|
result=self.bot.bbs.dbdo(db,op,data)
|
||||||
|
|
||||||
######################################################################## BOOMBOX MAIN 1
|
######################################################################## BOOMBOX MAIN 1
|
||||||
|
######################################################################## BOOMBOX MAIN 1
|
||||||
|
|
||||||
@command(permission='view',public=True, show_in_help_list=False)
|
@command(permission='view',public=True, show_in_help_list=False)
|
||||||
def bb(self, mask, target, args):
|
def bb(self, mask, target, args):
|
||||||
"""Convert boombox token to a url
|
"""Convert boombox token to a url
|
||||||
@ -88,40 +148,66 @@ class Plugin:
|
|||||||
else:
|
else:
|
||||||
msg+=f"{c[2]}error{c[1]}: {c[3]}{token} is an invalid token"
|
msg+=f"{c[2]}error{c[1]}: {c[3]}{token} is an invalid token"
|
||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
######################################################################## BOOMBOX MAIN 2
|
######################################################################## BOOMBOX MAIN 2
|
||||||
|
######################################################################## BOOMBOX MAIN 2
|
||||||
|
|
||||||
@command(permission='view',error_format="{cmd} error - usage: ?{cmd} all,top,old,user,site - example: ?{cmd} all".format)
|
@command(permission='view',error_format="{cmd} error - usage: ?{cmd} all,top,old,user,site - example: ?{cmd} all".format)
|
||||||
def boombox(self, mask, target, args):
|
def boombox(self, mask, target, args):
|
||||||
"""boombox
|
"""boombox
|
||||||
%%boombox
|
%%boombox
|
||||||
"""
|
"""
|
||||||
command='all'
|
command='all'
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
commands=['top','old','user','site','all']
|
commands=['top','old','user','site','all']
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if not command in commands:
|
if not command in commands:
|
||||||
msg="boombox - usage: ?boombox top, ?boombox old, ?boombox user, ?boombox site, ?boombox all"
|
msg="boombox - usage: ?boombox top, ?boombox old, ?boombox user, ?boombox site, ?boombox all"
|
||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
bbs_last=self.bot.db.getlist("bbs_last")
|
bbs_last=self.bot.db.getlist("bbs_last")
|
||||||
bbs_data=self.bot.db.getlist('bbs_data')
|
bbs_data=self.bot.db.getlist('bbs_data')
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if bbs_data:
|
if bbs_data:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
c1,c2,c3,c4,c5,c6,c7,c8=self.bot.bbs.c
|
c1,c2,c3,c4,c5,c6,c7,c8=self.bot.bbs.c
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
if command=='all':
|
if command=='all':
|
||||||
for _ in MOTD.splitlines():
|
for _ in MOTD.splitlines():
|
||||||
if _:
|
if _:
|
||||||
self.bot.privmsg(target,f'{self.bot.bbs.palette()[0]}{_}')
|
self.bot.privmsg(target,f'{self.bot.bbs.palette()[0]}{_}')
|
||||||
###################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
if command=='top' or command=='all':
|
if command=='top' or command=='all':
|
||||||
# TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP
|
# TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP
|
||||||
# TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP
|
# TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP
|
||||||
# TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP
|
# TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP SONGS TOP
|
||||||
msg=f'TOP SONGS ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
msg=f'TOP SONGS ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
bbs_data=self.bot.db.getlist('bbs_data')
|
bbs_data=self.bot.db.getlist('bbs_data')
|
||||||
hits=[]
|
hits=[]
|
||||||
@ -133,13 +219,19 @@ class Plugin:
|
|||||||
nl.append(max(lot,key=lambda x: x[1]))
|
nl.append(max(lot,key=lambda x: x[1]))
|
||||||
lot.remove(nl[-1])
|
lot.remove(nl[-1])
|
||||||
nl[0:len(bbs_data)]
|
nl[0:len(bbs_data)]
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
mode_length=0
|
mode_length=0
|
||||||
if command=='top':
|
if command=='top':
|
||||||
mode_length=self.bot.bbs.ceiling__top_songs
|
mode_length=self.bot.bbs.ceiling__top_songs
|
||||||
elif command=='all':
|
elif command=='all':
|
||||||
mode_length=self.bot.bbs.floor__top_songs
|
mode_length=self.bot.bbs.floor__top_songs
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
top_songs=[]
|
top_songs=[]
|
||||||
for i in range(mode_length):
|
for i in range(mode_length):
|
||||||
try:
|
try:
|
||||||
@ -166,12 +258,19 @@ class Plugin:
|
|||||||
break
|
break
|
||||||
last_song=song
|
last_song=song
|
||||||
self.bot.privmsg(target,song)
|
self.bot.privmsg(target,song)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
if command=='old' or command=='all':
|
if command=='old' or command=='all':
|
||||||
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
|
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
|
||||||
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
|
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
|
||||||
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
|
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
|
||||||
msg=f'OLD SONGS ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
msg=f'OLD SONGS ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
bbs_data=self.bot.db.getlist('bbs_data')
|
bbs_data=self.bot.db.getlist('bbs_data')
|
||||||
last_songs=[]
|
last_songs=[]
|
||||||
@ -192,28 +291,42 @@ class Plugin:
|
|||||||
if len(lastdb)>0:
|
if len(lastdb)>0:
|
||||||
msg=f'{c4}{self.bot.bbs.tailor(title.lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site.lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(nick.lower(),10)} {c1}╏ {c7}{str(plays).zfill(2)}{c1}/{c7}{str(hits).zfill(2)} {c6}plays {c1}╏ {c5}?bb {token}'
|
msg=f'{c4}{self.bot.bbs.tailor(title.lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site.lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(nick.lower(),10)} {c1}╏ {c7}{str(plays).zfill(2)}{c1}/{c7}{str(hits).zfill(2)} {c6}plays {c1}╏ {c5}?bb {token}'
|
||||||
last_songs.append(msg)
|
last_songs.append(msg)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'<<< _____boombox_plugin >>> boombox:last - error: {e}')
|
print(f'<<< _____boombox_plugin >>> boombox:last - error: {e}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
mode_length=0
|
mode_length=0
|
||||||
if command=='old':
|
if command=='old':
|
||||||
mode_length=self.bot.bbs.ceiling__last_songs
|
mode_length=self.bot.bbs.ceiling__last_songs
|
||||||
elif command=='all':
|
elif command=='all':
|
||||||
mode_length=self.bot.bbs.floor__last_songs
|
mode_length=self.bot.bbs.floor__last_songs
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i in range(mode_length):
|
for i in range(mode_length):
|
||||||
self.bot.privmsg(target,last_songs[i])
|
self.bot.privmsg(target,last_songs[i])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
if command=='user' or command=='all':
|
if command=='user' or command=='all':
|
||||||
# TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP
|
# TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP
|
||||||
# TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP
|
# TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP
|
||||||
# TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP
|
# TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP USERS TOP
|
||||||
msg=f'TOP USERS ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
msg=f'TOP USERS ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
top_data=self.bot.db.getlist('bbs_data')
|
top_data=self.bot.db.getlist('bbs_data')
|
||||||
bbs_nicks=self.bot.db.getlist("bbs_nicks")
|
bbs_nicks=self.bot.db.getlist("bbs_nicks")
|
||||||
@ -247,43 +360,88 @@ class Plugin:
|
|||||||
top_token=bbs_data[top_index]['token']
|
top_token=bbs_data[top_index]['token']
|
||||||
msg=f'{c4}{self.bot.bbs.tailor(top_title.lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(top_site.lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(top_user.lower(),10)} {c1}╏ {c7}{str(top_hits).zfill(2)}{c1}/{c7}{str(top_hits_site).zfill(2)} {c6}plays {c1}╏ {c5}?bb {top_token}'
|
msg=f'{c4}{self.bot.bbs.tailor(top_title.lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(top_site.lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(top_user.lower(),10)} {c1}╏ {c7}{str(top_hits).zfill(2)}{c1}/{c7}{str(top_hits_site).zfill(2)} {c6}plays {c1}╏ {c5}?bb {top_token}'
|
||||||
top_users.append(msg)
|
top_users.append(msg)
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
mode_length=0
|
mode_length=0
|
||||||
if command=='user':
|
if command=='user':
|
||||||
mode_length=self.bot.bbs.ceiling__top_users
|
mode_length=self.bot.bbs.ceiling__top_users
|
||||||
elif command=='all':
|
elif command=='all':
|
||||||
mode_length=self.bot.bbs.floor__top_users
|
mode_length=self.bot.bbs.floor__top_users
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i in range(mode_length):
|
for i in range(mode_length):
|
||||||
self.bot.privmsg(target,top_users[i])
|
self.bot.privmsg(target,top_users[i])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
if command=='site' or command=='all':
|
if command=='site' or command=='all':
|
||||||
# TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP
|
# TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP
|
||||||
# TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP
|
# TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP
|
||||||
# TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP
|
# TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP SITES TOP
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
bbs_sites=self.bot.db.getlist("bbs_sites")
|
bbs_sites=self.bot.db.getlist("bbs_sites")
|
||||||
msg=f'TOP SITES ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
msg=f'TOP SITES ◸{c2}◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸◹◸'
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
bbs_nicks=self.bot.db.getlist('bbs_nicks')
|
bbs_nicks=self.bot.db.getlist('bbs_nicks')
|
||||||
site_nicks=list(bbs_nicks[0].keys())
|
site_nicks=list(bbs_nicks[0].keys())
|
||||||
site_users_bandcamp=[]; site_users_soundcloud=[]; site_users_spotify=[];
|
site_users_bandcamp=[]; site_users_soundcloud=[]; site_users_spotify=[];
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
site_users_youtube=[];
|
site_users_youtube=[];
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
for _ in [ x for x in site_nicks ]:
|
for _ in [ x for x in site_nicks ]:
|
||||||
site_users_bandcamp.append([bbs_nicks[0][_]['bandcamp'],_])
|
site_users_bandcamp.append([bbs_nicks[0][_]['bandcamp'],_])
|
||||||
site_users_soundcloud.append([bbs_nicks[0][_]['soundcloud'],_])
|
site_users_soundcloud.append([bbs_nicks[0][_]['soundcloud'],_])
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
site_users_youtube.append([bbs_nicks[0][_]['youtube'],_])
|
site_users_youtube.append([bbs_nicks[0][_]['youtube'],_])
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
site_users_spotify.append([bbs_nicks[0][_]['spotify'],_])
|
site_users_spotify.append([bbs_nicks[0][_]['spotify'],_])
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
site_users_bandcamp.sort(); site_users_bandcamp.reverse()
|
site_users_bandcamp.sort(); site_users_bandcamp.reverse()
|
||||||
site_users_soundcloud.sort(); site_users_soundcloud.reverse()
|
site_users_soundcloud.sort(); site_users_soundcloud.reverse()
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
site_users_youtube.sort(); site_users_youtube.reverse()
|
site_users_youtube.sort(); site_users_youtube.reverse()
|
||||||
site_users_spotify.sort(); site_users_spotify.reverse()
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
site_users_spotify.sort(); site_users_spotify.reverse()
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
try:
|
||||||
bandcamp_top_user_hits=[]
|
bandcamp_top_user_hits=[]
|
||||||
for i,_ in enumerate(bbs_data):
|
for i,_ in enumerate(bbs_data):
|
||||||
if _['site']=='bandcamp':
|
if _['site']=='bandcamp':
|
||||||
@ -299,7 +457,13 @@ class Plugin:
|
|||||||
bandcamp_sitehits=bbs_sites[0]['bandcamp']
|
bandcamp_sitehits=bbs_sites[0]['bandcamp']
|
||||||
bandcamp_token=bbs_data[bandcamp_index]['token']
|
bandcamp_token=bbs_data[bandcamp_index]['token']
|
||||||
site_bandcamp=[bandcamp_title,bandcamp_site,bandcamp_user,bandcamp_userhits,bandcamp_sitehits,bandcamp_token,bandcamp_index]
|
site_bandcamp=[bandcamp_title,bandcamp_site,bandcamp_user,bandcamp_userhits,bandcamp_sitehits,bandcamp_token,bandcamp_index]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
try:
|
||||||
soundcloud_top_user_hits=[]
|
soundcloud_top_user_hits=[]
|
||||||
for i,_ in enumerate(bbs_data):
|
for i,_ in enumerate(bbs_data):
|
||||||
if _['site']=='soundcloud':
|
if _['site']=='soundcloud':
|
||||||
@ -315,8 +479,17 @@ class Plugin:
|
|||||||
soundcloud_sitehits=bbs_sites[0]['soundcloud']
|
soundcloud_sitehits=bbs_sites[0]['soundcloud']
|
||||||
soundcloud_token=bbs_data[soundcloud_index]['token']
|
soundcloud_token=bbs_data[soundcloud_index]['token']
|
||||||
site_soundcloud=[soundcloud_title,soundcloud_site,soundcloud_user,soundcloud_userhits,soundcloud_sitehits,soundcloud_token,soundcloud_index]
|
site_soundcloud=[soundcloud_title,soundcloud_site,soundcloud_user,soundcloud_userhits,soundcloud_sitehits,soundcloud_token,soundcloud_index]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
|
try:
|
||||||
youtube_top_user_hits=[]
|
youtube_top_user_hits=[]
|
||||||
for i,_ in enumerate(bbs_data):
|
for i,_ in enumerate(bbs_data):
|
||||||
if _['site']=='youtube':
|
if _['site']=='youtube':
|
||||||
@ -332,7 +505,13 @@ class Plugin:
|
|||||||
youtube_sitehits=bbs_sites[0]['youtube']
|
youtube_sitehits=bbs_sites[0]['youtube']
|
||||||
youtube_token=bbs_data[youtube_index]['token']
|
youtube_token=bbs_data[youtube_index]['token']
|
||||||
site_youtube=[youtube_title,youtube_site,youtube_user,youtube_userhits,youtube_sitehits,youtube_token,youtube_index]
|
site_youtube=[youtube_title,youtube_site,youtube_user,youtube_userhits,youtube_sitehits,youtube_token,youtube_index]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
|
try:
|
||||||
spotify_top_user_hits=[]
|
spotify_top_user_hits=[]
|
||||||
for i,_ in enumerate(bbs_data):
|
for i,_ in enumerate(bbs_data):
|
||||||
if _['site']=='spotify':
|
if _['site']=='spotify':
|
||||||
@ -348,7 +527,12 @@ class Plugin:
|
|||||||
spotify_sitehits=bbs_sites[0]['spotify']
|
spotify_sitehits=bbs_sites[0]['spotify']
|
||||||
spotify_token=bbs_data[spotify_index]['token']
|
spotify_token=bbs_data[spotify_index]['token']
|
||||||
site_spotify=[spotify_title,spotify_site,spotify_user,spotify_userhits,spotify_sitehits,spotify_token,spotify_index]
|
site_spotify=[spotify_title,spotify_site,spotify_user,spotify_userhits,spotify_sitehits,spotify_token,spotify_index]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
bbs_sites=self.bot.db.getlist("bbs_sites")
|
bbs_sites=self.bot.db.getlist("bbs_sites")
|
||||||
hits=[]
|
hits=[]
|
||||||
for i,data in enumerate(bbs_sites[0].keys()):
|
for i,data in enumerate(bbs_sites[0].keys()):
|
||||||
@ -363,35 +547,60 @@ class Plugin:
|
|||||||
top_sites=[]
|
top_sites=[]
|
||||||
for site in siteorder:
|
for site in siteorder:
|
||||||
if site=='soundcloud':
|
if site=='soundcloud':
|
||||||
|
try:
|
||||||
msg=f'{c4}{self.bot.bbs.tailor(site_soundcloud[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_soundcloud[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_soundcloud[2].lower(),10)} {c1}╏ {c7}{str(site_soundcloud[3]).zfill(2)}{c1}/{c7}{str(site_soundcloud[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_soundcloud[5]}'
|
msg=f'{c4}{self.bot.bbs.tailor(site_soundcloud[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_soundcloud[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_soundcloud[2].lower(),10)} {c1}╏ {c7}{str(site_soundcloud[3]).zfill(2)}{c1}/{c7}{str(site_soundcloud[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_soundcloud[5]}'
|
||||||
top_sites.append(msg)
|
top_sites.append(msg)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
elif site=='bandcamp':
|
elif site=='bandcamp':
|
||||||
|
try:
|
||||||
msg=f'{c4}{self.bot.bbs.tailor(site_bandcamp[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_bandcamp[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_bandcamp[2].lower(),10)} {c1}╏ {c7}{str(site_bandcamp[3]).zfill(2)}{c1}/{c7}{str(site_bandcamp[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_bandcamp[5]}'
|
msg=f'{c4}{self.bot.bbs.tailor(site_bandcamp[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_bandcamp[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_bandcamp[2].lower(),10)} {c1}╏ {c7}{str(site_bandcamp[3]).zfill(2)}{c1}/{c7}{str(site_bandcamp[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_bandcamp[5]}'
|
||||||
top_sites.append(msg)
|
top_sites.append(msg)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
##########################################
|
||||||
elif SERVICES_YOUTUBE and site=='youtube':
|
elif SERVICES_YOUTUBE and site=='youtube':
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
try:
|
||||||
msg=f'{c4}{self.bot.bbs.tailor(site_youtube[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_youtube[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_youtube[2].lower(),10)} {c1}╏ {c7}{str(site_youtube[3]).zfill(2)}{c1}/{c7}{str(site_youtube[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_youtube[5]}'
|
msg=f'{c4}{self.bot.bbs.tailor(site_youtube[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_youtube[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_youtube[2].lower(),10)} {c1}╏ {c7}{str(site_youtube[3]).zfill(2)}{c1}/{c7}{str(site_youtube[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_youtube[5]}'
|
||||||
top_sites.append(msg)
|
top_sites.append(msg)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
elif site=='spotify':
|
elif site=='spotify':
|
||||||
|
try:
|
||||||
msg=f'{c4}{self.bot.bbs.tailor(site_spotify[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_spotify[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_spotify[2].lower(),10)} {c1}╏ {c7}{str(site_spotify[3]).zfill(2)}{c1}/{c7}{str(site_spotify[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_spotify[5]}'
|
msg=f'{c4}{self.bot.bbs.tailor(site_spotify[0].lower(),50)} {c1}╏ {c3}{self.bot.bbs.tailor(site_spotify[1].lower(),10)} {c1}╏ {c8}{self.bot.bbs.tailor(site_spotify[2].lower(),10)} {c1}╏ {c7}{str(site_spotify[3]).zfill(2)}{c1}/{c7}{str(site_spotify[4]).zfill(2)} {c6}plays {c1}╏ {c5}?bb {site_spotify[5]}'
|
||||||
top_sites.append(msg)
|
top_sites.append(msg)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
mode_length=0
|
mode_length=0
|
||||||
if command=='site':
|
if command=='site':
|
||||||
mode_length=self.bot.bbs.ceiling__top_sites
|
mode_length=self.bot.bbs.ceiling__top_sites
|
||||||
elif command=='all':
|
elif command=='all':
|
||||||
mode_length=self.bot.bbs.floor__top_sites
|
mode_length=self.bot.bbs.floor__top_sites
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i in range(mode_length):
|
for i in range(mode_length):
|
||||||
self.bot.privmsg(target,top_sites[i])
|
self.bot.privmsg(target,top_sites[i])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
###################################################################################
|
|
||||||
###################################################################### BOOMBOX CONFIG ENTRY
|
###################################################################### BOOMBOX CONFIG ENTRY
|
||||||
|
###################################################################### BOOMBOX CONFIG ENTRY
|
||||||
|
|
||||||
class BOOMBOX_CONFIG:
|
class BOOMBOX_CONFIG:
|
||||||
|
|
||||||
################################################################### BOOMBOX CONFIG INIT
|
################################################################### BOOMBOX CONFIG INIT
|
||||||
|
################################################################### BOOMBOX CONFIG INIT
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
try:
|
try:
|
||||||
bool(dims.checked)
|
bool(dims.checked)
|
||||||
@ -406,7 +615,7 @@ class BOOMBOX_CONFIG:
|
|||||||
for index,database in enumerate(self.database_names):
|
for index,database in enumerate(self.database_names):
|
||||||
db=self.bot.db.getlist(database)
|
db=self.bot.db.getlist(database)
|
||||||
if not db:
|
if not db:
|
||||||
print(f'<<< _____boombox_plugin >>> [ {" "*19}{index+1}/{len(self.database_names)} ] - [ missing database: {self.database_names[index]} ]')
|
print(f'<<< _____boombox_plugin >>> [ {index+1}/{len(self.database_names)} ] - [ missing database: {self.database_names[index]} ]')
|
||||||
self.db_diagnostics(database)
|
self.db_diagnostics(database)
|
||||||
else:
|
else:
|
||||||
print(f'<<< _____boombox_plugin >>> [ {index+1}/{len(self.database_names)} ] - [ located database: {self.database_names[index]} ]')
|
print(f'<<< _____boombox_plugin >>> [ {index+1}/{len(self.database_names)} ] - [ located database: {self.database_names[index]} ]')
|
||||||
@ -419,7 +628,10 @@ class BOOMBOX_CONFIG:
|
|||||||
for _ in self.database_names:
|
for _ in self.database_names:
|
||||||
self.bot.bbdb.append(self.bot.db.getlist(_))
|
self.bot.bbdb.append(self.bot.db.getlist(_))
|
||||||
dims.checked=False
|
dims.checked=False
|
||||||
|
|
||||||
############################################################ BOOMBOX CONFIG COLOR CODES
|
############################################################ BOOMBOX CONFIG COLOR CODES
|
||||||
|
############################################################ BOOMBOX CONFIG COLOR CODES
|
||||||
|
|
||||||
def color(self,c):
|
def color(self,c):
|
||||||
try:
|
try:
|
||||||
c=str(c.lower())
|
c=str(c.lower())
|
||||||
@ -446,7 +658,10 @@ class BOOMBOX_CONFIG:
|
|||||||
except:
|
except:
|
||||||
print('color: error')
|
print('color: error')
|
||||||
return '\x0f'
|
return '\x0f'
|
||||||
|
|
||||||
############################################################# BOOMBOX CONFIG COLOR SETS
|
############################################################# BOOMBOX CONFIG COLOR SETS
|
||||||
|
############################################################# BOOMBOX CONFIG COLOR SETS
|
||||||
|
|
||||||
def palette(self):
|
def palette(self):
|
||||||
self.c=[]; self.n=[]
|
self.c=[]; self.n=[]
|
||||||
for i in range(0,8):
|
for i in range(0,8):
|
||||||
@ -454,14 +669,20 @@ class BOOMBOX_CONFIG:
|
|||||||
c=self.color(hex(n)[2:])
|
c=self.color(hex(n)[2:])
|
||||||
self.c.append(c); self.n.append(n)
|
self.c.append(c); self.n.append(n)
|
||||||
return self.c
|
return self.c
|
||||||
|
|
||||||
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
||||||
|
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
||||||
|
|
||||||
def tailor(self,s,n):
|
def tailor(self,s,n):
|
||||||
if len(s)<=n:
|
if len(s)<=n:
|
||||||
result=s+"."*(n-len(s))
|
result=s+"."*(n-len(s))
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
return s[0:n]
|
return s[0:n]
|
||||||
|
|
||||||
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
||||||
|
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
||||||
|
|
||||||
def dbsync(self,db):
|
def dbsync(self,db):
|
||||||
for i,database in enumerate(['bbs_data','bbs_last','bbs_nicks','bbs_sites','bbs_token','bbs_tokenmirror']):
|
for i,database in enumerate(['bbs_data','bbs_last','bbs_nicks','bbs_sites','bbs_token','bbs_tokenmirror']):
|
||||||
if db == database:
|
if db == database:
|
||||||
@ -469,13 +690,15 @@ class BOOMBOX_CONFIG:
|
|||||||
db_stored=self.bot.db.getlist(database)
|
db_stored=self.bot.db.getlist(database)
|
||||||
db_memory=self.bot.bbdb[i]
|
db_memory=self.bot.bbdb[i]
|
||||||
if not db_memory==db_stored:
|
if not db_memory==db_stored:
|
||||||
self.bot.db.setlist(database,db_memory)
|
self.bot.db.setlist(database,db_memory); # print('<<< _____boombox_plugin >>> success: storage database updated from memory')
|
||||||
print('<<< _____boombox_plugin >>> success: storage database updated from memory')
|
|
||||||
else:
|
else:
|
||||||
print('<<< _____boombox_plugin >>> aborted: storage database same as memory content')
|
pass; # print('<<< _____boombox_plugin >>> aborted: storage database same as memory content')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('<<< _____boombox_plugin >>> dbsync:error - failed in writing to storage database from memory: {e}')
|
print('<<< _____boombox_plugin >>> dbsync:error - failed in writing to storage database from memory: {e}')
|
||||||
|
|
||||||
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
||||||
|
######################################################## BOOMBOX CONFIG TEXT ALIGNMENTS
|
||||||
|
|
||||||
def dbdo(self,database,operation,data=""):
|
def dbdo(self,database,operation,data=""):
|
||||||
database_names=(['bbs_data','bbs_last','bbs_nicks','bbs_sites','bbs_token','bbs_tokenmirror'])
|
database_names=(['bbs_data','bbs_last','bbs_nicks','bbs_sites','bbs_token','bbs_tokenmirror'])
|
||||||
operations=['get','set','update','append']
|
operations=['get','set','update','append']
|
||||||
@ -486,39 +709,56 @@ class BOOMBOX_CONFIG:
|
|||||||
return self.bot.bbdb[index]
|
return self.bot.bbdb[index]
|
||||||
elif operation=='set':
|
elif operation=='set':
|
||||||
db_stored=self.bot.db.getlist(database)
|
db_stored=self.bot.db.getlist(database)
|
||||||
print(f'<<< _____boombox_plugin >>> pre:{database} db_stored: {db_stored}')
|
# print(f'<<< _____boombox_plugin >>> pre:{database} db_stored: {db_stored}')
|
||||||
print(f'<<< _____boombox_plugin >>> pre:{database} db_memory: {self.bot.bbdb[index]}')
|
# print(f'<<< _____boombox_plugin >>> pre:{database} db_memory: {self.bot.bbdb[index]}')
|
||||||
print(f'<<< _____boombox_plugin >>> pre:{database} db_sent: {data}')
|
# print(f'<<< _____boombox_plugin >>> pre:{database} db_sent: {data}')
|
||||||
self.bot.bbdb[index]=data
|
self.bot.bbdb[index]=data
|
||||||
print(f'<<< _____boombox_plugin >>> post:{database} db_memory: {self.bot.bbdb[index]}')
|
# print(f'<<< _____boombox_plugin >>> post:{database} db_memory: {self.bot.bbdb[index]}')
|
||||||
print(f'<<< _____boombox_plugin >>> writing from memory to storage')
|
# print(f'<<< _____boombox_plugin >>> writing from memory to storage')
|
||||||
self.dbsync(database)
|
self.dbsync(database)
|
||||||
elif operation=='append':
|
elif operation=='append':
|
||||||
db_stored=self.bot.db.getlist(database)
|
db_stored=self.bot.db.getlist(database)
|
||||||
print(f'<<< _____boombox_plugin >>> pre:{database} db_stored: {db_stored}')
|
# print(f'<<< _____boombox_plugin >>> pre:{database} db_stored: {db_stored}')
|
||||||
print(f'<<< _____boombox_plugin >>> pre:{database} db_memory: {self.bot.bbdb[index]}')
|
# print(f'<<< _____boombox_plugin >>> pre:{database} db_memory: {self.bot.bbdb[index]}')
|
||||||
self.bot.bbdb[index].append(data)
|
self.bot.bbdb[index].append(data)
|
||||||
print(f'<<< _____boombox_plugin >>> post:{database} db_memory: {self.bot.bbdb[index]}')
|
# print(f'<<< _____boombox_plugin >>> post:{database} db_memory: {self.bot.bbdb[index]}')
|
||||||
print(f'<<< _____boombox_plugin >>> writing from memory to storage')
|
# print(f'<<< _____boombox_plugin >>> writing from memory to storage')
|
||||||
self.dbsync(database)
|
self.dbsync(database)
|
||||||
|
|
||||||
#################################################### BOOMBOX CONFIG DATABASE OPERATIONS
|
#################################################### BOOMBOX CONFIG DATABASE OPERATIONS
|
||||||
|
#################################################### BOOMBOX CONFIG DATABASE OPERATIONS
|
||||||
|
|
||||||
def push(self,nick,site,title,token,url):
|
def push(self,nick,site,title,token,url):
|
||||||
nick=self.no_unicode(nick)
|
nick=self.no_unicode(nick)
|
||||||
title=self.no_unicode(title)
|
title=self.no_unicode(title)
|
||||||
bbs_data=self.dbdo('bbs_data','get')
|
bbs_data=self.dbdo('bbs_data','get')
|
||||||
bbs_last=self.dbdo('bbs_last','get')
|
bbs_last=self.dbdo('bbs_last','get')
|
||||||
|
# try:
|
||||||
|
# if len(bbs_last)==1:
|
||||||
|
# bbs_last=bbs_last+bbs_last
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
bbs_last=bbs_last[-1:]+bbs_last[:-1]
|
bbs_last=bbs_last[-1:]+bbs_last[:-1]
|
||||||
bbs_last[0]=[nick,site,title,token,url]
|
bbs_last[0]=[nick,site,title,token,url]
|
||||||
self.dbdo('bbs_last','set',bbs_last)
|
self.dbdo('bbs_last','set',bbs_last)
|
||||||
|
|
||||||
#################################################### BOOMBOX CONFIG DATABASE OPERATIONS
|
#################################################### BOOMBOX CONFIG DATABASE OPERATIONS
|
||||||
|
#################################################### BOOMBOX CONFIG DATABASE OPERATIONS
|
||||||
|
|
||||||
def check(self,nick,site,data):
|
def check(self,nick,site,data):
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
bbs_nicks=self.dbdo('bbs_nicks','get')
|
bbs_nicks=self.dbdo('bbs_nicks','get')
|
||||||
bbs_sites=self.dbdo('bbs_sites','get')
|
bbs_sites=self.dbdo('bbs_sites','get')
|
||||||
bbs_data=self.dbdo('bbs_data','get')
|
bbs_data=self.dbdo('bbs_data','get')
|
||||||
bbs_token=self.dbdo('bbs_token','get')
|
bbs_token=self.dbdo('bbs_token','get')
|
||||||
bbs_tokenmirror=self.dbdo('bbs_tokenmirror','get')
|
bbs_tokenmirror=self.dbdo('bbs_tokenmirror','get')
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if bbs_data:
|
if bbs_data:
|
||||||
for i,_data in enumerate(bbs_data):
|
for i,_data in enumerate(bbs_data):
|
||||||
@ -540,14 +780,20 @@ class BOOMBOX_CONFIG:
|
|||||||
self.dbdo("bbs_sites",'set',bbs_sites)
|
self.dbdo("bbs_sites",'set',bbs_sites)
|
||||||
self.dbdo("bbs_data",'set',bbs_data)
|
self.dbdo("bbs_data",'set',bbs_data)
|
||||||
return
|
return
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bbs_nicks[0][nick]['tally']+=1
|
bbs_nicks[0][nick]['tally']+=1
|
||||||
bbs_nicks[0][nick][site]+=1
|
bbs_nicks[0][nick][site]+=1
|
||||||
except:
|
except:
|
||||||
bbs_nicks[0].update({nick:{'tally':1,'bandcamp':0,'soundcloud':0,'spotify':0,'youtube':0}})
|
bbs_nicks[0].update({nick:{'tally':1,'bandcamp':0,'soundcloud':0,'spotify':0,'youtube':0}})
|
||||||
bbs_nicks[0][nick][site]+=1
|
bbs_nicks[0][nick][site]+=1
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
self.dbdo("bbs_nicks",'set',bbs_nicks)
|
self.dbdo("bbs_nicks",'set',bbs_nicks)
|
||||||
bbs_sites[0][site]+=1
|
bbs_sites[0][site]+=1
|
||||||
self.dbdo("bbs_sites",'set',bbs_sites)
|
self.dbdo("bbs_sites",'set',bbs_sites)
|
||||||
@ -574,46 +820,85 @@ class BOOMBOX_CONFIG:
|
|||||||
self.dbdo('bbs_token',{TOKEN:URL})
|
self.dbdo('bbs_token',{TOKEN:URL})
|
||||||
self.dbdo('bbs_tokenmirror','append',{URL:TOKEN})
|
self.dbdo('bbs_tokenmirror','append',{URL:TOKEN})
|
||||||
self.dbdo('bbs_tokenmirror','set',bbs_tokenmirror)
|
self.dbdo('bbs_tokenmirror','set',bbs_tokenmirror)
|
||||||
|
|
||||||
################################### BOOMBOX CONFIG HOOKED EXTERNALS DATABASE OPERATIONS
|
################################### BOOMBOX CONFIG HOOKED EXTERNALS DATABASE OPERATIONS
|
||||||
|
################################### BOOMBOX CONFIG HOOKED EXTERNALS DATABASE OPERATIONS
|
||||||
|
|
||||||
def getsite(self,url):
|
def getsite(self,url):
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
sites=['soundcloud','spotify','bandcamp']
|
sites=['soundcloud','spotify','bandcamp']
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
sites.append('youtube')
|
sites.append('youtube')
|
||||||
|
|
||||||
if not url.find('soundcloud.com')==-1:
|
if not url.find('soundcloud.com')==-1:
|
||||||
return sites[0]
|
return sites[0]
|
||||||
if SERVICES_YOUTUBE and not url.find('youtube.com')==-1 or not url.find('youtu.be')==-1:
|
|
||||||
return sites[1]
|
|
||||||
if not url.find('spotify.com')==-1:
|
if not url.find('spotify.com')==-1:
|
||||||
return sites[2]
|
return sites[1]
|
||||||
if not url.find('bandcamp.com')==-1:
|
if not url.find('bandcamp.com')==-1:
|
||||||
|
return sites[2]
|
||||||
|
|
||||||
|
#########################################################
|
||||||
|
if SERVICES_YOUTUBE and not url.find('youtube.com')==-1 \
|
||||||
|
or not url.find('youtu.be')==-1:
|
||||||
|
#########################################################
|
||||||
|
|
||||||
return sites[3]
|
return sites[3]
|
||||||
|
|
||||||
################################### BOOMBOX CONFIG HOOKED EXTERNALS DATABASE OPERATIONS
|
################################### BOOMBOX CONFIG HOOKED EXTERNALS DATABASE OPERATIONS
|
||||||
|
################################### BOOMBOX CONFIG HOOKED EXTERNALS DATABASE OPERATIONS
|
||||||
|
|
||||||
def enter(self,nick,url,title):
|
def enter(self,nick,url,title):
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
timestamp=datetime.now().timestamp()
|
timestamp=datetime.now().timestamp()
|
||||||
token=self.token(url)
|
token=self.token(url)
|
||||||
bbs_token=self.dbdo('bbs_token','get')
|
bbs_token=self.dbdo('bbs_token','get')
|
||||||
nick=self.no_unicode(nick)
|
nick=self.no_unicode(nick)
|
||||||
title=self.no_unicode(title).lower()
|
title=self.no_unicode(title).lower()
|
||||||
site=self.getsite(url)
|
site=self.getsite(url)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
data={'nicks':{nick:1},'title':title.lower(),'url':url,'token':token,'timestamp':timestamp,'site':site,'hits':1}
|
data={'nicks':{nick:1},'title':title.lower(),'url':url,'token':token,'timestamp':timestamp,'site':site,'hits':1}
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if site=='soundcloud':
|
if site=='soundcloud':
|
||||||
title=title[:title.rfind('by')].replace('Stream','').strip().lower()
|
|
||||||
if not title=='SoundCloud - Hear the world’s sound':
|
if not title=='SoundCloud - Hear the world’s sound':
|
||||||
data['title']=title.split('music |')[0].rstrip().lower()
|
if not title.rfind('by') == -1:
|
||||||
|
data['title']=title[title.rfind('by')+3:].replace('Stream','').strip().lower() + ' - ' + title[:title.rfind('by')].replace('Stream','').strip().lower()
|
||||||
|
else:
|
||||||
|
data['title']=title.replace('listen to ','')
|
||||||
data=self.check(nick,site,data)
|
data=self.check(nick,site,data)
|
||||||
self.push(nick.lower(),site,title.lower(),token,url)
|
self.push(nick.lower(),site,title.lower(),token,url)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
########################################
|
||||||
if SERVICES_YOUTUBE and site=='youtube':
|
if SERVICES_YOUTUBE and site=='youtube':
|
||||||
|
########################################
|
||||||
|
|
||||||
id=url[-11:]
|
id=url[-11:]
|
||||||
result=self.bot.videos_list_by_id(id=id)
|
result=self.bot.videos_list_by_id(id=id)
|
||||||
if result:
|
if result:
|
||||||
data=self.check(nick,site,data)
|
data=self.check(nick,site,data)
|
||||||
self.push(nick.lower(),site,title.lower(),token,url)
|
self.push(nick.lower(),site,title.lower(),token,url)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if site=='spotify':
|
if site=='spotify':
|
||||||
offset=url.rfind('/')+1
|
offset=url.rfind('/')+1
|
||||||
try:
|
try:
|
||||||
@ -632,13 +917,16 @@ class BOOMBOX_CONFIG:
|
|||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
title=title.lower()
|
title=title.lower()
|
||||||
|
|
||||||
if track and artist:
|
if track and artist:
|
||||||
title=f'{artist} - {track}'.lower()
|
title=f'{artist} - {track}'.lower()
|
||||||
data['title']=title
|
data['title']=title
|
||||||
data=self.check(nick,site,data)
|
data=self.check(nick,site,data)
|
||||||
self.push(nick.lower(),site,title.lower(),token,url)
|
self.push(nick.lower(),site,title.lower(),token,url)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
|
||||||
if site=='bandcamp':
|
if site=='bandcamp':
|
||||||
offset=url.rfind('/')+1
|
offset=url.rfind('/')+1
|
||||||
try:
|
try:
|
||||||
@ -654,7 +942,10 @@ class BOOMBOX_CONFIG:
|
|||||||
data['title']=title.lower()
|
data['title']=title.lower()
|
||||||
data=self.check(nick,site,data)
|
data=self.check(nick,site,data)
|
||||||
self.push(nick.lower(),site,title.lower(),token,url)
|
self.push(nick.lower(),site,title.lower(),token,url)
|
||||||
|
|
||||||
########################################### BOOMBOX CONFIG DATABASE OPERATIONS FOR URLS
|
########################################### BOOMBOX CONFIG DATABASE OPERATIONS FOR URLS
|
||||||
|
########################################### BOOMBOX CONFIG DATABASE OPERATIONS FOR URLS
|
||||||
|
|
||||||
def token(self,url):
|
def token(self,url):
|
||||||
bbs_token=self.dbdo('bbs_token','get')
|
bbs_token=self.dbdo('bbs_token','get')
|
||||||
bbs_tokenmirror=self.dbdo('bbs_tokenmirror','get')
|
bbs_tokenmirror=self.dbdo('bbs_tokenmirror','get')
|
||||||
@ -665,13 +956,19 @@ class BOOMBOX_CONFIG:
|
|||||||
S=list(string.ascii_letters+string.digits)
|
S=list(string.ascii_letters+string.digits)
|
||||||
random.shuffle(S); S=''.join(S)[:5]
|
random.shuffle(S); S=''.join(S)[:5]
|
||||||
return f'{S}'
|
return f'{S}'
|
||||||
|
|
||||||
#################################### BOOMBOX CONFIG TEXT FILTERING BY STRIPPING UNICODE
|
#################################### BOOMBOX CONFIG TEXT FILTERING BY STRIPPING UNICODE
|
||||||
|
#################################### BOOMBOX CONFIG TEXT FILTERING BY STRIPPING UNICODE
|
||||||
|
|
||||||
def no_unicode(self,s):
|
def no_unicode(self,s):
|
||||||
if len(s) < 1: return s
|
if len(s) < 1: return s
|
||||||
s=s.encode('ascii','ignore').decode()
|
s=s.encode('ascii','ignore').decode()
|
||||||
s=s.strip().replace(' ',' ')
|
s=s.strip().replace(' ',' ')
|
||||||
return s
|
return s
|
||||||
|
|
||||||
##### BOOMBOX CONFIG DB OPERATIONS - SUB-SCANNING RECORDS RETURNING CONDITIONAL BOOLEAN
|
##### BOOMBOX CONFIG DB OPERATIONS - SUB-SCANNING RECORDS RETURNING CONDITIONAL BOOLEAN
|
||||||
|
##### BOOMBOX CONFIG DB OPERATIONS - SUB-SCANNING RECORDS RETURNING CONDITIONAL BOOLEAN
|
||||||
|
|
||||||
def dbskim(self,db,s):
|
def dbskim(self,db,s):
|
||||||
buffer=self.dbdo(db,'get')
|
buffer=self.dbdo(db,'get')
|
||||||
for _ in buffer:
|
for _ in buffer:
|
||||||
@ -681,7 +978,10 @@ class BOOMBOX_CONFIG:
|
|||||||
return result
|
return result
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
##### BOOMBOX CONFIG DB OPERATIONS - SUB-SCANNING RECORDS RETURNING CONDITIONAL BOOLEAN
|
##### BOOMBOX CONFIG DB OPERATIONS - SUB-SCANNING RECORDS RETURNING CONDITIONAL BOOLEAN
|
||||||
|
##### BOOMBOX CONFIG DB OPERATIONS - SUB-SCANNING RECORDS RETURNING CONDITIONAL BOOLEAN
|
||||||
|
|
||||||
def dbgaze(self,db,key,s):
|
def dbgaze(self,db,key,s):
|
||||||
buffer=self.dbdo(db,'get')
|
buffer=self.dbdo(db,'get')
|
||||||
for i,_ in enumerate(buffer):
|
for i,_ in enumerate(buffer):
|
||||||
@ -691,25 +991,48 @@ class BOOMBOX_CONFIG:
|
|||||||
return i
|
return i
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
##### BOOMBOX CONFIG DB OPERATIONS - AUTOMATICALLY CREATES/REPAIRS/STAGES THE DATABASES
|
##### BOOMBOX CONFIG DB OPERATIONS - AUTOMATICALLY CREATES/REPAIRS/STAGES THE DATABASES
|
||||||
|
##### BOOMBOX CONFIG DB OPERATIONS - AUTOMATICALLY CREATES/REPAIRS/STAGES THE DATABASES
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def db_diagnostics(self,database_name,*args):
|
def db_diagnostics(self,database_name,*args):
|
||||||
#######################################################################################
|
|
||||||
# database_names = ['bbs_data','bbs_last','bbs_nicks','bbs_sites','bbs_token','bbs_tokenmirror']
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
#
|
||||||
|
# database_names
|
||||||
|
#
|
||||||
|
# ['bbs_data','bbs_last','bbs_nicks','bbs_sites','bbs_token','bbs_tokenmirror']
|
||||||
|
#
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
index=-1
|
index=-1
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
for i, database in enumerate(self.database_names):
|
for i, database in enumerate(self.database_names):
|
||||||
if database_name==database:
|
if database_name==database:
|
||||||
index=i
|
index=i
|
||||||
break
|
break
|
||||||
print(f"<<< _____boombox_plugin >>> [ db_diagnostics - index: {index} - database: {database_name} ]")
|
print(f"<<< _____boombox_plugin >>> [ db_diagnostics - index: {index} - database: {database_name} ]")
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
print(f'<<< _____boombox_plugin >>> [{index+1}/{len(self.database_names)}] - [ creating database: {self.database_names[index]} ]')
|
###################################################################################
|
||||||
|
|
||||||
|
print(f'<<< _____boombox_plugin >>> [ {index+1}/{len(self.database_names)} ] - [ creating database: {self.database_names[index]} ]')
|
||||||
automation_flag=False
|
automation_flag=False
|
||||||
|
|
||||||
########################################################## database: 0/5 - bbs_data
|
########################################################## database: 0/5 - bbs_data
|
||||||
|
########################################################## database: 0/5 - bbs_data
|
||||||
|
|
||||||
if database_name==self.database_names[0]:
|
if database_name==self.database_names[0]:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db=[]
|
db=[]
|
||||||
db.append({'nicks':{"dr1p":1},'title':'fenix flexin - 10 toes ( dr1ph0p m1x )','url':'https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x','token':'06660','timestamp':1658706829.869036,'site':'soundcloud','hits':1})
|
db.append({'nicks':{"dr1p":1},'title':'fenix flexin - 10 toes ( dr1ph0p m1x )','url':'https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x','token':'06660','timestamp':1658706829.869036,'site':'soundcloud','hits':1})
|
||||||
@ -717,13 +1040,18 @@ class BOOMBOX_CONFIG:
|
|||||||
if db: automation_flag=not automation_flag
|
if db: automation_flag=not automation_flag
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
########################################################## database: 1/5 - bbs_last
|
########################################################## database: 1/5 - bbs_last
|
||||||
|
########################################################## database: 1/5 - bbs_last
|
||||||
|
|
||||||
elif database_name==self.database_names[1]:
|
elif database_name==self.database_names[1]:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db=[]
|
db=[]
|
||||||
for _ in range(0,self.bot.bbs.ceiling__last_songs):
|
for _ in range(0,self.bot.ceiling__last_songs):
|
||||||
db.append('')
|
db.append('')
|
||||||
db.pop()
|
db.pop()
|
||||||
db.append(["dr1p","soundcloud","fenix flexin - 10 toes ( dr1ph0p m1x )","06660","https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x"])
|
db.append(["dr1p","soundcloud","fenix flexin - 10 toes ( dr1ph0p m1x )","06660","https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x"])
|
||||||
@ -732,10 +1060,15 @@ class BOOMBOX_CONFIG:
|
|||||||
if db: automation_flag=not automation_flag
|
if db: automation_flag=not automation_flag
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
######################################################### database: 2/5 - bbs_nicks
|
######################################################### database: 2/5 - bbs_nicks
|
||||||
|
######################################################### database: 2/5 - bbs_nicks
|
||||||
|
|
||||||
elif database_name==self.database_names[2]:
|
elif database_name==self.database_names[2]:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db=[]
|
db=[]
|
||||||
db.append({'dr1p':{'tally':1,'bandcamp':0,'soundcloud':1,'spotify':0,'youtube':0}})
|
db.append({'dr1p':{'tally':1,'bandcamp':0,'soundcloud':1,'spotify':0,'youtube':0}})
|
||||||
@ -743,10 +1076,15 @@ class BOOMBOX_CONFIG:
|
|||||||
if db: automation_flag=not automation_flag
|
if db: automation_flag=not automation_flag
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
##########################################################database: 3/5 - bbs_sites
|
##########################################################database: 3/5 - bbs_sites
|
||||||
|
##########################################################database: 3/5 - bbs_sites
|
||||||
|
|
||||||
elif database_name==self.database_names[3]:
|
elif database_name==self.database_names[3]:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db=[]
|
db=[]
|
||||||
db.append({'soundcloud':1,'youtube':0,'spotify':0,'bandcamp':0})
|
db.append({'soundcloud':1,'youtube':0,'spotify':0,'bandcamp':0})
|
||||||
@ -754,10 +1092,15 @@ class BOOMBOX_CONFIG:
|
|||||||
if db: automation_flag=not automation_flag
|
if db: automation_flag=not automation_flag
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
######################################################### database: 4/5 - bbs_token
|
######################################################### database: 4/5 - bbs_token
|
||||||
|
######################################################### database: 4/5 - bbs_token
|
||||||
|
|
||||||
elif database_name==self.database_names[4]:
|
elif database_name==self.database_names[4]:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db=[]
|
db=[]
|
||||||
db.append({'06660':'https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x'})
|
db.append({'06660':'https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x'})
|
||||||
@ -765,10 +1108,15 @@ class BOOMBOX_CONFIG:
|
|||||||
if db: automation_flag=not automation_flag
|
if db: automation_flag=not automation_flag
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
################################################### database: 5/5 - bbs_tokenmirror
|
################################################### database: 5/5 - bbs_tokenmirror
|
||||||
|
################################################### database: 5/5 - bbs_tokenmirror
|
||||||
|
|
||||||
elif database_name==self.database_names[5]:
|
elif database_name==self.database_names[5]:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db=[]
|
db=[]
|
||||||
db.append({'https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x':'06660'})
|
db.append({'https://soundcloud.com/vanta_sec/fenix-flexin-10-toes-dr1ph0p-m1x':'06660'})
|
||||||
@ -776,14 +1124,16 @@ class BOOMBOX_CONFIG:
|
|||||||
if db: automation_flag=not automation_flag
|
if db: automation_flag=not automation_flag
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
msg=f'<<< _____boombox_plugin >>> [{index+1}/{len(self.database_names)}] - [ {self.database_names[index]} created ]'
|
###################################################################################
|
||||||
|
|
||||||
|
msg=f'<<< _____boombox_plugin >>> [ {index+1}/{len(self.database_names)} ] - [ {self.database_names[index]} created ]'
|
||||||
if automation_flag:
|
if automation_flag:
|
||||||
status='+++ success +++'
|
status='+++ success +++'
|
||||||
else:
|
else:
|
||||||
status='--- failure ---'
|
status='--- failure ---'
|
||||||
print(f'{msg} {status}')
|
print(f'{msg} {status}')
|
||||||
###################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,27 +1,44 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???DISCORD???
|
???DISCORD???
|
||||||
???TELEGRAM???
|
???TELEGRAM???
|
||||||
???MATRIX???
|
???MATRIX???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
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
|
from plugins.tool_dims_plugin import dims
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
|
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
async def listrooms(self,sender_netroomchan,sender_user,target,):
|
async def listrooms(self,sender_netroomchan,sender_user,target,):
|
||||||
@ -31,19 +48,46 @@ class Plugin:
|
|||||||
results=[]
|
results=[]
|
||||||
result=dims.list_channels()
|
result=dims.list_channels()
|
||||||
for _ in result:
|
for _ in result:
|
||||||
|
|
||||||
|
#########################################
|
||||||
if SERVICES_MATRIX and _.startswith('!'):
|
if SERVICES_MATRIX and _.startswith('!'):
|
||||||
|
#########################################
|
||||||
|
|
||||||
room=f'__matrix: {_}'
|
room=f'__matrix: {_}'
|
||||||
|
|
||||||
|
#######################
|
||||||
elif _.startswith('#'):
|
elif _.startswith('#'):
|
||||||
|
#######################
|
||||||
|
|
||||||
room=f'_____irc: {_}'
|
room=f'_____irc: {_}'
|
||||||
|
|
||||||
|
#############################################
|
||||||
elif SERVICES_TELEGRAM and _.startswith('$'):
|
elif SERVICES_TELEGRAM and _.startswith('$'):
|
||||||
|
#############################################
|
||||||
|
|
||||||
room=f'telegram: {_}'
|
room=f'telegram: {_}'
|
||||||
|
|
||||||
|
############################################
|
||||||
elif SERVICES_DISCORD and _.startswith('^'):
|
elif SERVICES_DISCORD and _.startswith('^'):
|
||||||
|
############################################
|
||||||
|
|
||||||
room=f'_discord: {_}'
|
room=f'_discord: {_}'
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
msg=f'<<< _____cmd_irc_plugin >>> [ ({sender_netroomchan})({sender_user})(listrooms)->({target}) ] - {room}'
|
msg=f'<<< _____cmd_irc_plugin >>> [ ({sender_netroomchan})({sender_user})(listrooms)->({target}) ] - {room}'
|
||||||
print(msg)
|
print(msg)
|
||||||
results.append(room)
|
results.append(room)
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
async def listbridges(self,sender_netroomchan,sender_user,target,):
|
async def listbridges(self,sender_netroomchan,sender_user,target,):
|
||||||
@ -76,7 +120,10 @@ class Plugin:
|
|||||||
else:
|
else:
|
||||||
results.append(f"{channel}")
|
results.append(f"{channel}")
|
||||||
return results
|
return results
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
async def addbridge(self,mask,target,args):
|
async def addbridge(self,mask,target,args):
|
||||||
@ -96,7 +143,10 @@ class Plugin:
|
|||||||
msg=f'<<< ________dims_plugin >>> [ addbridge ] - {src_outbound} -> {dest_inbound} - {status}'
|
msg=f'<<< ________dims_plugin >>> [ addbridge ] - {src_outbound} -> {dest_inbound} - {status}'
|
||||||
print(msg)
|
print(msg)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
async def delbridge(self,mask,target,args):
|
async def delbridge(self,mask,target,args):
|
||||||
@ -116,7 +166,10 @@ class Plugin:
|
|||||||
msg=f'<<< ________dims_plugin >>> [ addbridge ] - {src_outbound} -> {dest_inbound} - {status}'
|
msg=f'<<< ________dims_plugin >>> [ addbridge ] - {src_outbound} -> {dest_inbound} - {status}'
|
||||||
print(msg)
|
print(msg)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
async def blackhole(self,mask,target,args):
|
async def blackhole(self,mask,target,args):
|
||||||
@ -134,6 +187,9 @@ class Plugin:
|
|||||||
self.blackhole.append(entry)
|
self.blackhole.append(entry)
|
||||||
return self.blackhole
|
return self.blackhole
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
src_blackhole=noise.split()[0]
|
src_blackhole=noise.split()[0]
|
||||||
command=noise.split()[1]
|
command=noise.split()[1]
|
||||||
results=[]
|
results=[]
|
||||||
@ -142,30 +198,47 @@ class Plugin:
|
|||||||
msg=f'<<< ________dims_plugin >>> [ addblackhole ] - {src_blackhole}'
|
msg=f'<<< ________dims_plugin >>> [ addblackhole ] - {src_blackhole}'
|
||||||
print(msg)
|
print(msg)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
async def purgebridges(self, mask=None, target=None, data=None, sender_user=None, sender_netroomchan=None, **kw):
|
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 - erases channel/room message history across nets
|
||||||
%%purgebridges
|
%%purgebridges
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
msg=f'<<< _____cmd_irc_plugin >>> [ ({mask.nick}{target}).purgebridges()->({target}) ] - purging'
|
msg=f'<<< _____cmd_irc_plugin >>> [ ({mask.nick}{target}).purgebridges()->({target}) ] - purging'
|
||||||
print(msg)
|
print(msg)
|
||||||
from plugins.net_discord_plugin import d_discord_cmd
|
from plugins.net_discord_plugin import d_discord_cmd
|
||||||
d_discord_cmd(target,"purgebridges")
|
d_discord_cmd(target,"purgebridges")
|
||||||
|
|
||||||
|
#####
|
||||||
else:
|
else:
|
||||||
|
#####
|
||||||
|
|
||||||
msg=f'<<< _____cmd_irc_plugin >>> [ ({mask.nick}{target}).purgebridges()->({target}) ] - command disabled, not servicing discord atm'
|
msg=f'<<< _____cmd_irc_plugin >>> [ ({mask.nick}{target}).purgebridges()->({target}) ] - command disabled, not servicing discord atm'
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
###################################################################### NET IRC - MAIN [4/4]
|
###################################################################### NET IRC - MAIN [4/4]
|
||||||
|
###################################################################### NET IRC - MAIN [4/4]
|
||||||
|
|
||||||
async def _d_cmd_irc(sender_netroomchan,sender_user,target,cmd,) -> None:
|
async def _d_cmd_irc(sender_netroomchan,sender_user,target,cmd,) -> None:
|
||||||
#######################################################################################
|
|
||||||
result=(await eval(f"guds.memory('ircbot').{cmd}")(sender_netroomchan=sender_netroomchan,sender_user=sender_user,target=target,cmd=cmd,))
|
result=(await eval(f"guds.memory('ircbot').{cmd}")(sender_netroomchan=sender_netroomchan,sender_user=sender_user,target=target,cmd=cmd,))
|
||||||
#######################################################################################
|
|
||||||
bridgedbus=(BUS(['#b0tsh0p','!OftXgmqAFOPEatmvLU:pcriot.org'])) # hardcoded channel, audit - maybe from debugging
|
bridgedbus=(BUS(['#b0tsh0p','!OftXgmqAFOPEatmvLU:pcriot.org'])) # hardcoded channel, audit - maybe from debugging
|
||||||
await bridgedbus.output([sender_netroomchan,sender_user],result) # hardcoded channel, audit - maybe from debugging
|
await bridgedbus.output([sender_netroomchan,sender_user],result) # hardcoded channel, audit - maybe from debugging
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def d_cmd_irc(sender_netroomchan,sender_user,target,cmd,):
|
def d_cmd_irc(sender_netroomchan,sender_user,target,cmd,):
|
||||||
self=guds.memory('ircbot')
|
self=guds.memory('ircbot')
|
||||||
asyncio.run_coroutine_threadsafe(_d_cmd_irc(sender_netroomchan,sender_user,target,cmd,),self.loop)
|
asyncio.run_coroutine_threadsafe(_d_cmd_irc(sender_netroomchan,sender_user,target,cmd,),self.loop)
|
||||||
####################################################################################### EOF#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.compat import asyncio
|
from irc3.compat import asyncio
|
||||||
from irc3 import utils
|
from irc3 import utils
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -11,6 +13,10 @@ import shlex
|
|||||||
import irc3
|
import irc3
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
__doc__ = '''
|
__doc__ = '''
|
||||||
==========================================
|
==========================================
|
||||||
:mod:`irc3.plugins.command` Command plugin
|
:mod:`irc3.plugins.command` Command plugin
|
||||||
@ -164,31 +170,46 @@ be called via all three names.
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class free_policy:
|
class free_policy:
|
||||||
"""Default policy"""
|
"""Default policy"""
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.context = bot
|
self.context = bot
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __call__(self, predicates, meth, client, target, args, **kwargs):
|
def __call__(self, predicates, meth, client, target, args, **kwargs):
|
||||||
return meth(client, target, args)
|
return meth(client, target, args)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class mask_based_policy:
|
class mask_based_policy:
|
||||||
"""Allow only valid masks. Able to take care or permissions"""
|
"""Allow only valid masks. Able to take care or permissions"""
|
||||||
|
|
||||||
key = __name__ + '.masks'
|
key = __name__ + '.masks'
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.context = bot
|
self.context = bot
|
||||||
self.log = logging.getLogger(__name__)
|
self.log = logging.getLogger(__name__)
|
||||||
self.log.debug('Masks: %r', self.masks)
|
self.log.debug('Masks: %r', self.masks)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def masks(self):
|
def masks(self):
|
||||||
masks = self.context.config[self.key]
|
masks = self.context.config[self.key]
|
||||||
if hasattr(self.context, 'db'):
|
if hasattr(self.context, 'db'):
|
||||||
# update config with storage values
|
|
||||||
try:
|
try:
|
||||||
value = self.context.db[self]
|
value = self.context.db[self]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -198,6 +219,9 @@ class mask_based_policy:
|
|||||||
masks.update(value)
|
masks.update(value)
|
||||||
return masks
|
return masks
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def has_permission(self, mask, permission):
|
def has_permission(self, mask, permission):
|
||||||
if permission is None:
|
if permission is None:
|
||||||
return True
|
return True
|
||||||
@ -210,6 +234,9 @@ class mask_based_policy:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __call__(self, predicates, meth, client, target, args, **kwargs):
|
def __call__(self, predicates, meth, client, target, args, **kwargs):
|
||||||
if self.has_permission(client, predicates.get('permission')):
|
if self.has_permission(client, predicates.get('permission')):
|
||||||
return meth(client, target, args)
|
return meth(client, target, args)
|
||||||
@ -218,12 +245,15 @@ class mask_based_policy:
|
|||||||
client.nick,
|
client.nick,
|
||||||
'You are not allowed to use the %r command' % cmd_name)
|
'You are not allowed to use the %r command' % cmd_name)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def attach_command(func, depth=2, **predicates):
|
def attach_command(func, depth=2, **predicates):
|
||||||
commands = predicates.pop('commands',
|
commands = predicates.pop('commands','irc3.plugins.command.Commands')
|
||||||
'irc3.plugins.command.Commands')
|
category = predicates.pop('venusian_category','irc3.plugins.command')
|
||||||
category = predicates.pop('venusian_category',
|
|
||||||
'irc3.plugins.command')
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def callback(context, name, ob):
|
def callback(context, name, ob):
|
||||||
obj = context.context
|
obj = context.context
|
||||||
@ -244,9 +274,14 @@ def attach_command(func, depth=2, **predicates):
|
|||||||
obj.log.debug('Register command %r %r', cmd_name, aliases)
|
obj.log.debug('Register command %r %r', cmd_name, aliases)
|
||||||
else:
|
else:
|
||||||
obj.log.debug('Register command %r', cmd_name)
|
obj.log.debug('Register command %r', cmd_name)
|
||||||
info = venusian.attach(func, callback,
|
|
||||||
category=category, depth=depth)
|
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
info = venusian.attach(func, callback,category=category, depth=depth)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def command(*func, **predicates):
|
def command(*func, **predicates):
|
||||||
if func:
|
if func:
|
||||||
@ -259,6 +294,8 @@ def command(*func, **predicates):
|
|||||||
return func
|
return func
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Commands(dict):
|
class Commands(dict):
|
||||||
@ -271,6 +308,9 @@ class Commands(dict):
|
|||||||
default_policy = free_policy
|
default_policy = free_policy
|
||||||
case_sensitive = False
|
case_sensitive = False
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
module = self.__class__.__module__
|
module = self.__class__.__module__
|
||||||
@ -278,34 +318,42 @@ class Commands(dict):
|
|||||||
self.log = logging.getLogger(module)
|
self.log = logging.getLogger(module)
|
||||||
self.log.debug('Config: %r', config)
|
self.log.debug('Config: %r', config)
|
||||||
|
|
||||||
if 'cmd' in context.config: # in case of
|
if 'cmd' in context.config:
|
||||||
config['cmd'] = context.config['cmd']
|
config['cmd'] = context.config['cmd']
|
||||||
context.config['cmd'] = self.cmd = config.get('cmd', '!')
|
context.config['cmd'] = self.cmd = config.get('cmd', '!')
|
||||||
context.config['re_cmd'] = re.escape(self.cmd)
|
context.config['re_cmd'] = re.escape(self.cmd)
|
||||||
|
|
||||||
self.use_shlex = self.config.get('use_shlex', True)
|
self.use_shlex = self.config.get('use_shlex', True)
|
||||||
self.antiflood = self.config.get('antiflood', False)
|
self.antiflood = self.config.get('antiflood', False)
|
||||||
self.case_sensitive = self.config.get('casesensitive',
|
self.case_sensitive = self.config.get('casesensitive',self.case_sensitive)
|
||||||
self.case_sensitive)
|
|
||||||
|
|
||||||
guard = utils.maybedotted(config.get('guard', self.default_policy))
|
guard = utils.maybedotted(config.get('guard', self.default_policy))
|
||||||
self.log.debug('Guard: %s', guard.__name__)
|
self.log.debug('Guard: %s', guard.__name__)
|
||||||
self.guard = guard(context)
|
self.guard = guard(context)
|
||||||
|
|
||||||
self.error_format = utils.maybedotted(config.get('error_format',
|
self.error_format = utils.maybedotted(config.get('error_format',"Invalid arguments.".format))
|
||||||
"Invalid arguments.".format))
|
|
||||||
self.handles = defaultdict(Done)
|
self.handles = defaultdict(Done)
|
||||||
self.tasks = defaultdict(Done)
|
self.tasks = defaultdict(Done)
|
||||||
|
|
||||||
self.aliases = {}
|
self.aliases = {}
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def split_command(self, data, use_shlex=None):
|
def split_command(self, data, use_shlex=None):
|
||||||
if not data:
|
if not data:
|
||||||
return []
|
return []
|
||||||
return shlex.split(data) if use_shlex else data.split(' ')
|
return shlex.split(data) if use_shlex else data.split(' ')
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event((r'(@(?P<tags>\S+) )?:(?P<mask>\S+) PRIVMSG (?P<target>\S+) '
|
@irc3.event((r'(@(?P<tags>\S+) )?:(?P<mask>\S+) PRIVMSG (?P<target>\S+) '
|
||||||
r':{re_cmd}(?P<cmd>[\w-]+)(\s+(?P<data>\S.*)|(\s*$))'))
|
r':{re_cmd}(?P<cmd>[\w-]+)(\s+(?P<data>\S.*)|(\s*$))'))
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def on_command(self, cmd, mask=None, target=None, client=None, **kw):
|
def on_command(self, cmd, mask=None, target=None, client=None, **kw):
|
||||||
if not self.case_sensitive:
|
if not self.case_sensitive:
|
||||||
cmd = cmd.lower()
|
cmd = cmd.lower()
|
||||||
@ -319,16 +367,18 @@ class Commands(dict):
|
|||||||
else:
|
else:
|
||||||
return self.do_command(predicates, meth, mask, target, **kw)
|
return self.do_command(predicates, meth, mask, target, **kw)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def do_command(self, predicates, meth, client, target, data=None, **kw):
|
def do_command(self, predicates, meth, client, target, data=None, **kw):
|
||||||
nick = self.context.nick or '-'
|
nick = self.context.nick or '-'
|
||||||
to = client.nick if target == nick else target
|
to = client.nick if target == nick else target
|
||||||
doc = meth.__doc__ or ''
|
doc = meth.__doc__ or ''
|
||||||
doc = [line.strip() for line in doc.strip().split('\n')]
|
doc = [line.strip() for line in doc.strip().split('\n')]
|
||||||
doc = [nick + ' ' + line.strip('%%')
|
doc = [nick + ' ' + line.strip('%%') for line in doc if line.startswith('%%')]
|
||||||
for line in doc if line.startswith('%%')]
|
|
||||||
doc = 'Usage:' + '\n ' + '\n '.join(doc)
|
doc = 'Usage:' + '\n ' + '\n '.join(doc)
|
||||||
if data:
|
if data:
|
||||||
if not isinstance(data, str): # pragma: no cover
|
if not isinstance(data, str):
|
||||||
encoding = self.context.encoding
|
encoding = self.context.encoding
|
||||||
data = data.encode(encoding)
|
data = data.encode(encoding)
|
||||||
try:
|
try:
|
||||||
@ -348,8 +398,7 @@ class Commands(dict):
|
|||||||
if not predicates.get('quiet', False):
|
if not predicates.get('quiet', False):
|
||||||
args = {'cmd': cmd_name, 'args': data,
|
args = {'cmd': cmd_name, 'args': data,
|
||||||
'args_str': " ".join(data), 'exc': exc}
|
'args_str': " ".join(data), 'exc': exc}
|
||||||
error_format = predicates.get('error_format',
|
error_format = predicates.get('error_format',self.error_format)
|
||||||
self.error_format)
|
|
||||||
self.context.privmsg(to, error_format(**args))
|
self.context.privmsg(to, error_format(**args))
|
||||||
else:
|
else:
|
||||||
uid = (cmd_name, to)
|
uid = (cmd_name, to)
|
||||||
@ -364,9 +413,7 @@ class Commands(dict):
|
|||||||
client if use_client else client.nick,
|
client if use_client else client.nick,
|
||||||
"Please be patient and don't flood me", nowait=True)
|
"Please be patient and don't flood me", nowait=True)
|
||||||
else:
|
else:
|
||||||
# get command result
|
|
||||||
res = self.guard(predicates, meth, client, target, args=args)
|
res = self.guard(predicates, meth, client, target, args=args)
|
||||||
|
|
||||||
callback = functools.partial(self.command_callback, uid, to)
|
callback = functools.partial(self.command_callback, uid, to)
|
||||||
if res is not None:
|
if res is not None:
|
||||||
coros = (
|
coros = (
|
||||||
@ -376,16 +423,17 @@ class Commands(dict):
|
|||||||
if any(coros):
|
if any(coros):
|
||||||
task = asyncio.ensure_future(
|
task = asyncio.ensure_future(
|
||||||
res, loop=self.context.loop)
|
res, loop=self.context.loop)
|
||||||
# use a callback if command is a coroutine
|
|
||||||
task.add_done_callback(callback)
|
task.add_done_callback(callback)
|
||||||
self.tasks[uid] = task
|
self.tasks[uid] = task
|
||||||
return task
|
return task
|
||||||
else:
|
else:
|
||||||
# no callback needed
|
|
||||||
callback(res)
|
callback(res)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def command_callback(self, uid, to, msgs):
|
def command_callback(self, uid, to, msgs):
|
||||||
if isinstance(msgs, asyncio.Future): # pragma: no cover
|
if isinstance(msgs, asyncio.Future):
|
||||||
msgs = msgs.result()
|
msgs = msgs.result()
|
||||||
if msgs is not None:
|
if msgs is not None:
|
||||||
def iterator(msgs):
|
def iterator(msgs):
|
||||||
@ -397,6 +445,9 @@ class Commands(dict):
|
|||||||
if handle is not None:
|
if handle is not None:
|
||||||
self.handles[uid] = handle
|
self.handles[uid] = handle
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command
|
@command
|
||||||
def help(self, mask, target, args):
|
def help(self, mask, target, args):
|
||||||
"""Show help
|
"""Show help
|
||||||
@ -448,15 +499,22 @@ class Commands(dict):
|
|||||||
if url:
|
if url:
|
||||||
yield 'Full help is available at ' + url
|
yield 'Full help is available at ' + url
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Commands %s>' % sorted([self.cmd + k for k in self.keys()])
|
return '<Commands %s>' % sorted([self.cmd + k for k in self.keys()])
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class Done:
|
class Done:
|
||||||
|
|
||||||
def done(self):
|
def done(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@command(permission='admin', show_in_help_list=False, public=False)
|
@command(permission='admin', show_in_help_list=False, public=False)
|
||||||
def ping(bot, mask, target, args):
|
def ping(bot, mask, target, args):
|
||||||
@ -466,6 +524,8 @@ def ping(bot, mask, target, args):
|
|||||||
"""
|
"""
|
||||||
bot.send('NOTICE %(nick)s :PONG %(nick)s!' % dict(nick=mask.nick))
|
bot.send('NOTICE %(nick)s :PONG %(nick)s!' % dict(nick=mask.nick))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@command(venusian_category='irc3.debug', show_in_help_list=False)
|
@command(venusian_category='irc3.debug', show_in_help_list=False)
|
||||||
def quote(bot, mask, target, args):
|
def quote(bot, mask, target, args):
|
||||||
@ -477,6 +537,8 @@ def quote(bot, mask, target, args):
|
|||||||
bot.log.info('quote> %r', msg)
|
bot.log.info('quote> %r', msg)
|
||||||
bot.send(msg)
|
bot.send(msg)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@command(venusian_category='irc3.debug', show_in_help_list=False)
|
@command(venusian_category='irc3.debug', show_in_help_list=False)
|
||||||
def reconnect(bot, mask, target, args):
|
def reconnect(bot, mask, target, args):
|
||||||
@ -487,6 +549,8 @@ def reconnect(bot, mask, target, args):
|
|||||||
plugin = bot.get_plugin(utils.maybedotted('irc3.plugins.core.Core'))
|
plugin = bot.get_plugin(utils.maybedotted('irc3.plugins.core.Core'))
|
||||||
bot.loop.call_soon(plugin.reconnect)
|
bot.loop.call_soon(plugin.reconnect)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def print_help_page(bot, file=sys.stdout):
|
def print_help_page(bot, file=sys.stdout):
|
||||||
@ -505,7 +569,6 @@ def print_help_page(bot, file=sys.stdout):
|
|||||||
for name, (predicates, callback) in plugin.items():
|
for name, (predicates, callback) in plugin.items():
|
||||||
commands = modules.setdefault(callback.__module__, [])
|
commands = modules.setdefault(callback.__module__, [])
|
||||||
commands.append((name, callback, predicates))
|
commands.append((name, callback, predicates))
|
||||||
|
|
||||||
for module in sorted(modules):
|
for module in sorted(modules):
|
||||||
p(module)
|
p(module)
|
||||||
p('=' * len(module))
|
p('=' * len(module))
|
||||||
@ -526,4 +589,6 @@ def print_help_page(bot, file=sys.stdout):
|
|||||||
if predicates.get('public', True) is False:
|
if predicates.get('public', True) is False:
|
||||||
p('*Only available in private.*')
|
p('*Only available in private.*')
|
||||||
p('')
|
p('')
|
||||||
#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,42 +1,77 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
import sys
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3,os,aiohttp, asyncio, async_timeout
|
import irc3,os,aiohttp, asyncio, async_timeout
|
||||||
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
CRYPTOCOMPARE_KEY=getenv('CRYPTOCOMPARE_KEY')
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
headers = { 'authorization': f'Apikey {CRYPTOCOMPARE_KEY}' }
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
try:
|
|
||||||
CRYPTOCOMPARE_KEY = os.environ['CRYPTOCOMPARE_KEY']
|
|
||||||
headers = { 'authorization': f'Apikey {CRYPTOCOMPARE_KEY}' }
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def cc(self, mask, target, args):
|
def cc(self, mask, target, args):
|
||||||
"""Show Crypto Value
|
"""Show Crypto Value
|
||||||
%%cc <coin>
|
%%cc <coin>
|
||||||
"""
|
"""
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
coin = args['<coin>'].upper()
|
coin = args['<coin>'].upper()
|
||||||
async def fetch(session, url):
|
async def fetch(session, url):
|
||||||
async with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
async with session.get(url) as response:
|
async with session.get(url) as response:
|
||||||
return await response.json()
|
return await response.json()
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
async def grab_url(url):
|
async def grab_url(url):
|
||||||
async with aiohttp.ClientSession(headers=headers) as session:
|
async with aiohttp.ClientSession(headers=headers) as session:
|
||||||
json_response = await fetch(session, url)
|
json_response = await fetch(session, url)
|
||||||
return json_response
|
return json_response
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
def parse_coin(response):
|
def parse_coin(response):
|
||||||
try:
|
try:
|
||||||
task_result, _ = response.result()
|
task_result, _ = response.result()
|
||||||
@ -46,7 +81,6 @@ class Plugin:
|
|||||||
price = rlist[1].get("USD")
|
price = rlist[1].get("USD")
|
||||||
price_multi = rlist[2].get("DISPLAY")[coin].get("USD", {})
|
price_multi = rlist[2].get("DISPLAY")[coin].get("USD", {})
|
||||||
daily_avg = rlist[0].get("USD")
|
daily_avg = rlist[0].get("USD")
|
||||||
|
|
||||||
elif rlist[2].get("USD"):
|
elif rlist[2].get("USD"):
|
||||||
price_multi = rlist[1].get("DISPLAY")[coin].get("USD", {})
|
price_multi = rlist[1].get("DISPLAY")[coin].get("USD", {})
|
||||||
price = rlist[2].get("USD")
|
price = rlist[2].get("USD")
|
||||||
@ -57,7 +91,6 @@ class Plugin:
|
|||||||
v = v.replace("$","").replace(" ","").replace(",","")
|
v = v.replace("$","").replace(" ","").replace(",","")
|
||||||
data_dict[k] = v
|
data_dict[k] = v
|
||||||
price_multi = data_dict
|
price_multi = data_dict
|
||||||
|
|
||||||
X = float(daily_avg) # AVERAGE OF THE DAY
|
X = float(daily_avg) # AVERAGE OF THE DAY
|
||||||
P = float(price_multi.get('PRICE')) # PRICE CURRENTLY
|
P = float(price_multi.get('PRICE')) # PRICE CURRENTLY
|
||||||
H = float(price_multi.get('HIGHDAY')) # HIGH OF THE DAY
|
H = float(price_multi.get('HIGHDAY')) # HIGH OF THE DAY
|
||||||
@ -65,7 +98,6 @@ class Plugin:
|
|||||||
A = float(price) # AGGREGATED EXCHANGE
|
A = float(price) # AGGREGATED EXCHANGE
|
||||||
Y = float(price_multi.get('CHANGE24HOUR')) # PRICE PERCENT DIFFERENTIAL 24 HOURS AGO
|
Y = float(price_multi.get('CHANGE24HOUR')) # PRICE PERCENT DIFFERENTIAL 24 HOURS AGO
|
||||||
C = float(price_multi.get('CHANGEPCT24HOUR'))
|
C = float(price_multi.get('CHANGEPCT24HOUR'))
|
||||||
|
|
||||||
if C <= 0:
|
if C <= 0:
|
||||||
C = "\x0304{}\x0F".format(C)
|
C = "\x0304{}\x0F".format(C)
|
||||||
else:
|
else:
|
||||||
@ -74,7 +106,6 @@ class Plugin:
|
|||||||
Y = "\x0304{}\x0F".format(Y)
|
Y = "\x0304{}\x0F".format(Y)
|
||||||
else:
|
else:
|
||||||
Y = "\x0303{}\x0F".format(Y)
|
Y = "\x0303{}\x0F".format(Y)
|
||||||
|
|
||||||
symbol = price_multi.get('FROMSYMBOL')
|
symbol = price_multi.get('FROMSYMBOL')
|
||||||
msg = "\x02\x0302[ {coin:}/{symbol:} ]\x0F @\x0303${p:,}\x0F ::: H\x0303${h:,}\x0F L\x0303${l:,}\x0F ::: Y${y:} @ %{c:} ::: X\x0303${x:,}\x0F A\x0303${a:,}\x0F".format(coin=coin, symbol=symbol, p=P, h=H, l=L, y=Y,c=C, x=X, a=A)
|
msg = "\x02\x0302[ {coin:}/{symbol:} ]\x0F @\x0303${p:,}\x0F ::: H\x0303${h:,}\x0F L\x0303${l:,}\x0F ::: Y${y:} @ %{c:} ::: X\x0303${x:,}\x0F A\x0303${a:,}\x0F".format(coin=coin, symbol=symbol, p=P, h=H, l=L, y=Y,c=C, x=X, a=A)
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
@ -82,8 +113,10 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = self.bot.emo('their api is glitching: check back later')
|
msg = self.bot.emo('their api is glitching: check back later')
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
def process_lookups(response):
|
def process_lookups(response):
|
||||||
try:
|
try:
|
||||||
html = response.result()
|
html = response.result()
|
||||||
@ -104,11 +137,13 @@ class Plugin:
|
|||||||
asyncio.ensure_future(grab_url(price_url))]
|
asyncio.ensure_future(grab_url(price_url))]
|
||||||
task = self.bot.create_task(asyncio.wait(tasks))
|
task = self.bot.create_task(asyncio.wait(tasks))
|
||||||
task.add_done_callback(parse_coin)
|
task.add_done_callback(parse_coin)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
url = "https://min-api.cryptocompare.com/data/all/coinlist"
|
url = "https://min-api.cryptocompare.com/data/all/coinlist"
|
||||||
asyncio.ensure_future(grab_url(url), loop=self.bot.loop).add_done_callback(process_lookups)
|
asyncio.ensure_future(grab_url(url), \
|
||||||
#######################################################################################
|
loop=self.bot.loop).add_done_callback(process_lookups)
|
||||||
#######################################################################################
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF#.[d].
|
####################################################################################### EOF
|
||||||
|
53
storage/bot/plugins/datetime_plugin.py
Normal file
53
storage/bot/plugins/datetime_plugin.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
from irc3.plugins.command import command
|
||||||
|
import irc3
|
||||||
|
from datetime import datetime as dt
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
@irc3.plugin
|
||||||
|
class Plugin:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def reload(cls, old):
|
||||||
|
return cls(old.bot)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def before_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def after_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
@command(permission='view')
|
||||||
|
def time(self, mask, target, args):
|
||||||
|
"""Show local server datetime info
|
||||||
|
%%time
|
||||||
|
"""
|
||||||
|
msg = "LOCAL SERVER TIME: {HOUR}:{MINUTE} {MONTH}/{DAY}/{YEAR}"
|
||||||
|
TIME = dt.now()
|
||||||
|
msg = msg.format(HOUR=TIME.hour,MINUTE=TIME.minute,MONTH=TIME.month,DAY=TIME.day,YEAR=TIME.year)
|
||||||
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*- ########################################################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
"""# MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
"""# MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh+MMMMMMMMMMMMMMhsMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh+MMMMMMMMMMMMMMhsMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm/ oMMMMMMMMMMMMMMm +NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm/ oMMMMMMMMMMMMMMm +NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
@ -31,6 +33,9 @@
|
|||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNs. -hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNs. -hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdyymMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM #"""
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdyymMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM #"""
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -43,7 +48,8 @@ from irc3.plugins.cron import cron
|
|||||||
|
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
|
|
||||||
#######################################################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
global REASSEMBLY
|
global REASSEMBLY
|
||||||
global iCount
|
global iCount
|
||||||
@ -59,29 +65,34 @@ ANSI_HOME='databases/ansi'
|
|||||||
if not os.path.exists(ANSI_HOME):
|
if not os.path.exists(ANSI_HOME):
|
||||||
os.mkdir(ANSI_HOME)
|
os.mkdir(ANSI_HOME)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
COLOR_SET_A = "\x1b[38;2;196;0;255m"
|
COLOR_SET_A = "\x1b[38;2;196;0;255m"
|
||||||
COLOR_SET_B = "\x1b[38;2;128;64;255m"
|
COLOR_SET_B = "\x1b[38;2;128;64;255m"
|
||||||
COLOR_SET_C = "\x1b[38;2;128;0;255m"
|
COLOR_SET_C = "\x1b[38;2;128;0;255m"
|
||||||
COLOR_SET_D = "\x1b[2;35m"
|
COLOR_SET_D = "\x1b[2;35m"
|
||||||
COLOR_SET_E = "\x1b[2;31m"
|
COLOR_SET_E = "\x1b[2;31m"
|
||||||
|
|
||||||
#######################################################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
############
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
############ ##########################################################################################################
|
|
||||||
|
|
||||||
############# #########################################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
#############
|
|
||||||
|
|
||||||
########################### #######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
class HYDRA_FILE_HANDLER():
|
class HYDRA_FILE_HANDLER():
|
||||||
###########################
|
|
||||||
|
|
||||||
###################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
###################
|
|
||||||
|
|
||||||
self.txt=[]
|
self.txt=[]
|
||||||
self.ans=[]
|
self.ans=[]
|
||||||
@ -89,15 +100,17 @@ class Plugin:
|
|||||||
|
|
||||||
self.ptr=[]
|
self.ptr=[]
|
||||||
|
|
||||||
########################### #######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
class DR1P_STATE_MACHINE():
|
class DR1P_STATE_MACHINE():
|
||||||
###########################
|
|
||||||
|
|
||||||
FLAGS = ['ESCAPED']
|
FLAGS = ['ESCAPED']
|
||||||
|
|
||||||
###################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
###################
|
|
||||||
|
|
||||||
self.ESCAPED = False
|
self.ESCAPED = False
|
||||||
self.ASSEMBLY = False
|
self.ASSEMBLY = False
|
||||||
@ -110,48 +123,51 @@ class Plugin:
|
|||||||
self.attr_last = False
|
self.attr_last = False
|
||||||
self.attr_reset = False
|
self.attr_reset = False
|
||||||
|
|
||||||
#################
|
###################################################################################
|
||||||
def fog(self, s):
|
###################################################################################
|
||||||
#################
|
|
||||||
|
def dog(self, s):
|
||||||
|
|
||||||
if DEBUGGING:
|
if DEBUGGING:
|
||||||
print(s)
|
print(s)
|
||||||
|
|
||||||
##################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def flip(self, b):
|
def flip(self, b):
|
||||||
##################
|
|
||||||
|
|
||||||
FLIP = ({'03': '1B5B'})
|
FLIP = ({'03': '1B5B'})
|
||||||
fog = self.fog
|
dog = self.dog
|
||||||
if b in FLIP:
|
if b in FLIP:
|
||||||
fog(f'flp:{b}>{FLIP[b]}')
|
dog(f'flp:{b}>{FLIP[b]}')
|
||||||
return FLIP[b]
|
return FLIP[b]
|
||||||
else:
|
else:
|
||||||
return b
|
return b
|
||||||
|
|
||||||
#################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def seq(self, b):
|
def seq(self, b):
|
||||||
#################
|
|
||||||
|
|
||||||
global REASSEMBLY
|
global REASSEMBLY
|
||||||
fog = self.fog
|
dog = self.dog
|
||||||
fog(f'\033[38;2;0;255;0mseq:{b}')
|
dog(f'\033[38;2;0;255;0mseq:{b}')
|
||||||
if b == "1B5B":
|
if b == "1B5B":
|
||||||
self.ack(flag="ESCAPED")
|
self.ack(flag="ESCAPED")
|
||||||
REASSEMBLY += str(b)
|
REASSEMBLY += str(b)
|
||||||
self.ASSEMBLY = False
|
self.ASSEMBLY = False
|
||||||
self.stack = []
|
self.stack = []
|
||||||
if self.interrupt:
|
if self.interrupt:
|
||||||
if DEBUGGING: fog(f'\033[38;2;255;0;0minterrupted')
|
if DEBUGGING: dog(f'\033[38;2;255;0;0minterrupted')
|
||||||
if int("30", 16) <= int(str(b), 16) <= int("39", 16):
|
if int("30", 16) <= int(str(b), 16) <= int("39", 16):
|
||||||
if DEBUGGING: fog('\n\033[38;2;255;255;255m<<< <<< BINGO - CODES >>> >>>\x1b[\x1b[92m')
|
if DEBUGGING: dog('\n\033[38;2;255;255;255m<<< <<< BINGO - CODES >>> >>>\x1b[\x1b[92m')
|
||||||
self.stack.append(b)
|
self.stack.append(b)
|
||||||
if DEBUGGING:
|
if DEBUGGING:
|
||||||
fog('')
|
dog('')
|
||||||
elif b == "2C":
|
elif b == "2C":
|
||||||
if DEBUGGING: fog('\n\033[38;2;0;255;255m<<< <<< BINGO - DELIMITER >>> >>>\x1b[\x1b[92m')
|
if DEBUGGING: dog('\n\033[38;2;0;255;255m<<< <<< BINGO - DELIMITER >>> >>>\x1b[\x1b[92m')
|
||||||
self.stack.append(b)
|
self.stack.append(b)
|
||||||
if DEBUGGING: fog('')
|
if DEBUGGING: dog('')
|
||||||
else:
|
else:
|
||||||
if self.interrupt == True and len(self.stack) >= 1:
|
if self.interrupt == True and len(self.stack) >= 1:
|
||||||
if not b == "1B" or not int("30", 16) <= int(str(b), 16) <= int("39", 16) or not b == "2C":
|
if not b == "1B" or not int("30", 16) <= int(str(b), 16) <= int("39", 16) or not b == "2C":
|
||||||
@ -205,7 +221,7 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
self.ASSEMBLY = False
|
self.ASSEMBLY = False
|
||||||
if DEBUGGING:
|
if DEBUGGING:
|
||||||
fog('')
|
dog('')
|
||||||
if self.ASSEMBLY:
|
if self.ASSEMBLY:
|
||||||
self.stack.append(b)
|
self.stack.append(b)
|
||||||
REASSEMBLY += b
|
REASSEMBLY += b
|
||||||
@ -223,11 +239,12 @@ class Plugin:
|
|||||||
REASSEMBLY += "1B5B306D0D0A"
|
REASSEMBLY += "1B5B306D0D0A"
|
||||||
return
|
return
|
||||||
|
|
||||||
###############################
|
###################################################################################
|
||||||
def ack(self, flag="", cmd=""):
|
###################################################################################
|
||||||
###############################
|
|
||||||
|
|
||||||
fog = self.fog
|
def ack(self, flag="", cmd=""):
|
||||||
|
|
||||||
|
dog = self.dog
|
||||||
if cmd == "escaped":
|
if cmd == "escaped":
|
||||||
if flag == "ESCAPED":
|
if flag == "ESCAPED":
|
||||||
return 1
|
return 1
|
||||||
@ -237,51 +254,53 @@ class Plugin:
|
|||||||
for i, _ in enumerate(self.FLAGS):
|
for i, _ in enumerate(self.FLAGS):
|
||||||
if eval(f"self.{self.FLAGS[i]}"):
|
if eval(f"self.{self.FLAGS[i]}"):
|
||||||
if DEBUGGING:
|
if DEBUGGING:
|
||||||
fog(f'\033[38;2;0;0;255m{_} FLAG IS {str(eval(f"self.{self.FLAGS[i]}")).upper()}')
|
dog(f'\033[38;2;0;0;255m{_} FLAG IS {str(eval(f"self.{self.FLAGS[i]}")).upper()}')
|
||||||
else:
|
else:
|
||||||
if flag in self.FLAGS:
|
if flag in self.FLAGS:
|
||||||
if flag == "ESCAPED":
|
if flag == "ESCAPED":
|
||||||
self.ESCAPED = not self.ESCAPED
|
self.ESCAPED = not self.ESCAPED
|
||||||
if DEBUGGING:
|
if DEBUGGING:
|
||||||
fog(f"ESCAPED flag set {self.ESCAPED}")
|
dog(f"ESCAPED flag set {self.ESCAPED}")
|
||||||
if self.ESCAPED:
|
if self.ESCAPED:
|
||||||
self.interrupt = 1
|
self.interrupt = 1
|
||||||
else:
|
else:
|
||||||
self.interrupt = 0
|
self.interrupt = 0
|
||||||
|
|
||||||
#################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def fmt(self, b):
|
def fmt(self, b):
|
||||||
#################
|
|
||||||
|
|
||||||
b = hex(int(b, 16))[2:].upper().zfill(2)
|
b = hex(int(b, 16))[2:].upper().zfill(2)
|
||||||
return b
|
return b
|
||||||
|
|
||||||
#################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def asm(self, b):
|
def asm(self, b):
|
||||||
#################
|
|
||||||
|
|
||||||
b = self.fmt(b)
|
b = self.fmt(b)
|
||||||
b = self.flip(b)
|
b = self.flip(b)
|
||||||
self.seq(b)
|
self.seq(b)
|
||||||
|
|
||||||
##################
|
###################################################################################
|
||||||
def push(self, b):
|
###################################################################################
|
||||||
##################
|
|
||||||
|
|
||||||
fog = self.fog
|
def push(self, b):
|
||||||
|
|
||||||
|
dog = self.dog
|
||||||
global iCount
|
global iCount
|
||||||
iCount += 1
|
iCount += 1
|
||||||
fog = self.fog
|
dog = self.dog
|
||||||
if DEBUGGING: fog(f'{COLOR_SET_B}{str(iCount).zfill(8)} {hex(iCount)[2:].zfill(8).upper()}{COLOR_SET_A}')
|
if DEBUGGING: dog(f'{COLOR_SET_B}{str(iCount).zfill(8)} {hex(iCount)[2:].zfill(8).upper()}{COLOR_SET_A}')
|
||||||
asm = self.asm
|
asm = self.asm
|
||||||
self.ack()
|
self.ack()
|
||||||
asm(b)
|
asm(b)
|
||||||
|
|
||||||
########################### #######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
##################################### #############################################################################
|
|
||||||
class ESCAPE_CODE_DETECTION_SYSTEM():
|
class ESCAPE_CODE_DETECTION_SYSTEM():
|
||||||
#####################################
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -306,11 +325,12 @@ class Plugin:
|
|||||||
self.STRINCREMENT = f"{str(INDEX)}".zfill(8)
|
self.STRINCREMENT = f"{str(INDEX)}".zfill(8)
|
||||||
self.FILENAME = f"{ANSI_HOME}/{FILE_PREFIX}{self.STRINCREMENT}.txt"
|
self.FILENAME = f"{ANSI_HOME}/{FILE_PREFIX}{self.STRINCREMENT}.txt"
|
||||||
|
|
||||||
self.f1 = open(self.FILENAME, "w") # file handle f1
|
self.f1 = open(self.FILENAME, "w")
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
#################################################
|
|
||||||
def push(self,nick,channel,dataline,hexdataline):
|
def push(self,nick,channel,dataline,hexdataline):
|
||||||
#################################################
|
|
||||||
|
|
||||||
if not self.buffering:
|
if not self.buffering:
|
||||||
self.sorting.append([nick,True,channel,[datetime.now().timestamp()],[dataline],[hexdataline]])
|
self.sorting.append([nick,True,channel,[datetime.now().timestamp()],[dataline],[hexdataline]])
|
||||||
@ -329,11 +349,10 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
##################################### #############################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
######################## ##########################################################################################
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
########################
|
|
||||||
|
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.bot.hfh = self.HYDRA_FILE_HANDLER()
|
self.bot.hfh = self.HYDRA_FILE_HANDLER()
|
||||||
@ -346,11 +365,11 @@ class Plugin:
|
|||||||
self.DELIMIT=False
|
self.DELIMIT=False
|
||||||
self.hexdataline=None
|
self.hexdataline=None
|
||||||
|
|
||||||
############
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
###################### ######################################################################################### find every instance of a string within a string
|
|
||||||
def depumper_reset(self):
|
def depumper_reset(self):
|
||||||
######################
|
|
||||||
|
|
||||||
self.bot.hfh = guds.memory('HYDRA_FILE_HANDLER')()
|
self.bot.hfh = guds.memory('HYDRA_FILE_HANDLER')()
|
||||||
self.bot.ecds = guds.memory('ESCAPE_CODE_DETECTION_SYSTEM')()
|
self.bot.ecds = guds.memory('ESCAPE_CODE_DETECTION_SYSTEM')()
|
||||||
@ -363,24 +382,24 @@ class Plugin:
|
|||||||
REASSEMBLY="1B5B306D"
|
REASSEMBLY="1B5B306D"
|
||||||
iCount=-1
|
iCount=-1
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
|
||||||
############
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
###################### ######################################################################################### find every instance of a string within a string
|
|
||||||
def findall(self,s,w):
|
def findall(self,s,w):
|
||||||
######################
|
|
||||||
|
|
||||||
result=[i for i in range(len(s)) if s.startswith(w, i)]
|
result=[i for i in range(len(s)) if s.startswith(w, i)]
|
||||||
|
|
||||||
#############
|
#############
|
||||||
return result
|
return result
|
||||||
#############
|
#############
|
||||||
|
|
||||||
############
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
####################### ######################################################################################## used to strip a string of escape codes
|
|
||||||
def stripcodes(self,s):
|
def stripcodes(self,s):
|
||||||
#######################
|
|
||||||
|
|
||||||
codes=[]
|
codes=[]
|
||||||
buffer=s
|
buffer=s
|
||||||
@ -402,11 +421,12 @@ class Plugin:
|
|||||||
return buffer
|
return buffer
|
||||||
#############
|
#############
|
||||||
|
|
||||||
############
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
################################################################################################################ used to make sure a string fits into a space
|
|
||||||
def padding(self,s,n):
|
def padding(self,s,n):
|
||||||
######################
|
|
||||||
|
|
||||||
pad=n-len(self.stripcodes(s))
|
pad=n-len(self.stripcodes(s))
|
||||||
padding=(" "*pad)
|
padding=(" "*pad)
|
||||||
@ -416,11 +436,11 @@ class Plugin:
|
|||||||
return s
|
return s
|
||||||
########
|
########
|
||||||
|
|
||||||
############
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
############################ ######################################################################################
|
|
||||||
def process_irc_codes(self,ecds):
|
def process_irc_codes(self,ecds):
|
||||||
############################
|
|
||||||
|
|
||||||
# self.bot = self
|
# self.bot = self
|
||||||
self.ecds = ecds
|
self.ecds = ecds
|
||||||
@ -430,9 +450,10 @@ class Plugin:
|
|||||||
|
|
||||||
for i in range(0,len(self.ecds.l)):
|
for i in range(0,len(self.ecds.l)):
|
||||||
|
|
||||||
#########################
|
################################
|
||||||
# REQUIRES MOTION FROM CRONJOB
|
# REQUIRES MOTION FROM CRONJOB #
|
||||||
#########################
|
################################
|
||||||
|
|
||||||
DYTE=hex(self.ecds.l[i])[2:].zfill(2).upper()
|
DYTE=hex(self.ecds.l[i])[2:].zfill(2).upper()
|
||||||
DINT=hex(self.ecds.l[i])
|
DINT=hex(self.ecds.l[i])
|
||||||
self.processing_byte.append(DYTE)
|
self.processing_byte.append(DYTE)
|
||||||
@ -491,12 +512,11 @@ class Plugin:
|
|||||||
return self.ecds.l
|
return self.ecds.l
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
#############################
|
#######################################################################################
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
#######################################################################################
|
||||||
########################################################################## ########################################
|
|
||||||
def on_privmsg(self, mask=None, event=None, target=None, data=None, **kw):
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
|
def on_privmsg(self, mask=None, event=None, target=None, data=None, **kw):
|
||||||
if mask.nick == self.bot.nick: return
|
if mask.nick == self.bot.nick: return
|
||||||
self.hexdataline = ''
|
self.hexdataline = ''
|
||||||
inverse = self.bot.ecds.REGEX.sub("", data)
|
inverse = self.bot.ecds.REGEX.sub("", data)
|
||||||
@ -505,17 +525,11 @@ class Plugin:
|
|||||||
self.hexdataline += hex(ord(c))[2:].upper()
|
self.hexdataline += hex(ord(c))[2:].upper()
|
||||||
self.bot.ecds.push(mask.nick, target, data, self.hexdataline)
|
self.bot.ecds.push(mask.nick, target, data, self.hexdataline)
|
||||||
|
|
||||||
################################################################################################################### DMZ
|
###########################################################################################
|
||||||
# DMZ #################################################################################################################
|
###########################################################################################
|
||||||
################################################################################################################### DMZ
|
|
||||||
|
|
||||||
######################
|
|
||||||
@cron('* * * * * */1')
|
@cron('* * * * * */1')
|
||||||
###################### ################################################################################################
|
|
||||||
|
|
||||||
###################### ################################################################################################
|
|
||||||
def ecds_cronjob(bot):
|
def ecds_cronjob(bot):
|
||||||
######################
|
|
||||||
|
|
||||||
ecds = bot.ecds
|
ecds = bot.ecds
|
||||||
|
|
||||||
@ -548,7 +562,7 @@ def ecds_cronjob(bot):
|
|||||||
ecds.sorting.remove(ecds.sorting[z])
|
ecds.sorting.remove(ecds.sorting[z])
|
||||||
ecds_sorted = ecds.sorted[-1]
|
ecds_sorted = ecds.sorted[-1]
|
||||||
for dataline in ecds_sorted[2]:
|
for dataline in ecds_sorted[2]:
|
||||||
ecds.f1.write(f"{dataline}\n") # file handle f1
|
ecds.f1.write(f"{dataline}\n")
|
||||||
# bot.privmsg(hydrachan,dataline)
|
# bot.privmsg(hydrachan,dataline)
|
||||||
|
|
||||||
########################
|
########################
|
||||||
@ -576,15 +590,15 @@ def ecds_cronjob(bot):
|
|||||||
ecds.buffering = False
|
ecds.buffering = False
|
||||||
|
|
||||||
|
|
||||||
bot.ecds.f1.close() # file handle f1
|
bot.ecds.f1.close()
|
||||||
print('\x1b[36m'+'█'*16+'\n█ \x1b[32mDEPUMPER █\n'+'█'*16)
|
print('\x1b[36m'+'█'*16+'\n█ \x1b[32mDEPUMPER █\n'+'█'*16)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT = ecds.FILENAME
|
ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT = ecds.FILENAME
|
||||||
ecds.OUT_FILE_CP437_ANS_ARTWORK_BIN = ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT+".ans"
|
ecds.OUT_FILE_CP437_ANS_ARTWORK_BIN = ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT+".ans"
|
||||||
ecds.f2 = open(ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT, "rb") # file handle f2
|
ecds.f2 = open(ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT, "rb")
|
||||||
ecds.l = ecds.f2.read() # file handle f2
|
ecds.l = ecds.f2.read()
|
||||||
ecds.f2.close() # file handle f2
|
ecds.f2.close()
|
||||||
except:
|
except:
|
||||||
print('\n\x1b[31mERROR: NO INPUT BUFFER/FILE')
|
print('\n\x1b[31mERROR: NO INPUT BUFFER/FILE')
|
||||||
|
|
||||||
@ -593,18 +607,16 @@ def ecds_cronjob(bot):
|
|||||||
print(chr(27)+"[2J")
|
print(chr(27)+"[2J")
|
||||||
print(f'\x1b[36mPROCESSING: {ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT}')
|
print(f'\x1b[36mPROCESSING: {ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT}')
|
||||||
|
|
||||||
#################################
|
# printhex(main(DR1P_STATE_MACHINE))
|
||||||
#################################printhex(main(DR1P_STATE_MACHINE))
|
|
||||||
#################################
|
###########################
|
||||||
bot.process_irc_codes(ecds)
|
bot.process_irc_codes(ecds)
|
||||||
#################################
|
###########################
|
||||||
#################################
|
|
||||||
#################################
|
|
||||||
|
|
||||||
irc_bytes = []
|
irc_bytes = []
|
||||||
for i in range(len(REASSEMBLY)//2):
|
for i in range(len(REASSEMBLY)//2):
|
||||||
irc_bytes.append(int(REASSEMBLY[i*2:i*2+2], 16))
|
irc_bytes.append(int(REASSEMBLY[i*2:i*2+2], 16))
|
||||||
bot.ecds.f3 = open(bot.ecds.OUT_FILE_CP437_ANS_ARTWORK_BIN, 'wb') # file handle f3
|
bot.ecds.f3 = open(bot.ecds.OUT_FILE_CP437_ANS_ARTWORK_BIN, 'wb')
|
||||||
bad_byte_seq = [226, 150, 172]
|
bad_byte_seq = [226, 150, 172]
|
||||||
good_byte_seq = []
|
good_byte_seq = []
|
||||||
rebuilt_bytes = []
|
rebuilt_bytes = []
|
||||||
@ -634,11 +646,11 @@ def ecds_cronjob(bot):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
irc_bytes = bytes(irc_bytes).decode().encode('cp437')
|
irc_bytes = bytes(irc_bytes).decode().encode('cp437')
|
||||||
bot.ecds.f3.write(irc_bytes) # file handle f3
|
bot.ecds.f3.write(irc_bytes)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"error: post-codec-conversion: {e}")
|
print(f"error: post-codec-conversion: {e}")
|
||||||
|
|
||||||
bot.ecds.f3.close() # file handle f3
|
bot.ecds.f3.close()
|
||||||
|
|
||||||
MSG=f'\x1b[32mSUCCESS:\n'
|
MSG=f'\x1b[32mSUCCESS:\n'
|
||||||
MSG+=f'\x1b[35mIN < PROCESSED: {bot.ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT}\n'
|
MSG+=f'\x1b[35mIN < PROCESSED: {bot.ecds.IN__FILE__UTF8_IRC_ARTWORK_TXT}\n'
|
||||||
@ -704,10 +716,12 @@ def ecds_cronjob(bot):
|
|||||||
del bot.ecds;
|
del bot.ecds;
|
||||||
bot.ecds = guds.memory('ESCAPE_CODE_DETECTION_SYSTEM')()
|
bot.ecds = guds.memory('ESCAPE_CODE_DETECTION_SYSTEM')()
|
||||||
bot.depumper_reset()
|
bot.depumper_reset()
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
################################################################################################################### EOF
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
"""# MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmyydMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
"""# MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmyydMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh- .sNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh- .sNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
@ -740,3 +754,6 @@ def ecds_cronjob(bot):
|
|||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN+ mMMMMMMMMMMMMMMo /mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN+ mMMMMMMMMMMMMMMo /mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMshMMMMMMMMMMMMMM+hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMshMMMMMMMMMMMMMM+hMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ####
|
||||||
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM #"""
|
#### MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM #"""
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,17 +1,29 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
####################################################################################### SOF
|
###########################################################################################
|
||||||
####################################################################################### SOF
|
|
||||||
|
"""
|
||||||
|
- spelling - `alternate ircnicks - direct reference` - done
|
||||||
|
- messages in instances - right now only a record of 1 is indicated and that is incorrect it's only referencing last_msg
|
||||||
|
- activity timestamps - `floored to hour so there are no morethan 24 per user per day`
|
||||||
|
"""
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import asyncio
|
import asyncio
|
||||||
import irc3
|
import irc3
|
||||||
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import timeago
|
import timeago
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
D="\x02\x0315"
|
D="\x02\x0315"
|
||||||
G="\x02\x0314"
|
G="\x02\x0314"
|
||||||
S="\x02\x0304"
|
S="\x02\x0304"
|
||||||
@ -19,11 +31,15 @@ P="\x02\x0305"
|
|||||||
X="\x02\x0307"
|
X="\x02\x0307"
|
||||||
R="\x02\x0302"
|
R="\x02\x0302"
|
||||||
B="\x02\x0312"
|
B="\x02\x0312"
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
class DBIO():
|
class DBIO():
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
history_threshold=1
|
history_threshold=1
|
||||||
idle_threshold=1
|
idle_threshold=1
|
||||||
faded_threshold=14
|
faded_threshold=14
|
||||||
@ -39,44 +55,79 @@ class DBIO():
|
|||||||
users=[]
|
users=[]
|
||||||
scanning=False
|
scanning=False
|
||||||
scanning_operation=False
|
scanning_operation=False
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
self.bot.dbio=DBIO()
|
self.bot.dbio=DBIO()
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.bot.dbio.hardchatters=self.bot.db.getlist("hardchatters", [])
|
self.bot.dbio.hardchatters=self.bot.db.getlist("hardchatters", [])
|
||||||
print('<<< loaded database >>> hardchatters')
|
print(f'<<< _________dsa_plugin >>> [ loaded database ] - hardchatters')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'error: dsa_plugin > __init__ > hardchatter storage database: {e}')
|
print(f'<<< _________dsa_plugin >>> [ __init__ ] - hardchatter storage database: {e}')
|
||||||
self.bot.dbio.hardchatters=[]
|
self.bot.dbio.hardchatters=[]
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.bot.dbio.lurkers=self.bot.db.getlist("lurkers", [])
|
self.bot.dbio.lurkers=self.bot.db.getlist("lurkers", [])
|
||||||
print('<<< loaded database >>> lurkers')
|
print(f'<<< _________dsa_plugin >>> [ loaded database ] - lurkers')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'error: dsa_plugin > __init__ > lurkers storage database: {e}')
|
print(f'<<< _________dsa_plugin >>> [ __init__ ] - lurkers storage database: {e}')
|
||||||
self.bot.dbio.lurkers=[]
|
self.bot.dbio.lurkers=[]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def reload(cls, old):
|
||||||
|
return cls(old.bot)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def before_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def after_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def log(self,s):
|
def log(self,s):
|
||||||
print(s)
|
print(s)
|
||||||
self.bot.dbio.LOG.append(s)
|
self.bot.dbio.LOG.append(s)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def log_play(self,target):
|
def log_play(self,target):
|
||||||
for _ in self.bot.dbio.LOG:
|
for _ in self.bot.dbio.LOG:
|
||||||
self.bot.privmsg(target,_);
|
self.bot.privmsg(target,_);
|
||||||
print(_)
|
print(_)
|
||||||
self.bot.dbio.LOG=[]
|
self.bot.dbio.LOG=[]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def dbentry_add(self,database,record):
|
def dbentry_add(self,database,record):
|
||||||
buffer=self.bot.db.getlist(database,[])
|
buffer=self.bot.db.getlist(database,[])
|
||||||
buffer.append(record)
|
buffer.append(record)
|
||||||
@ -85,8 +136,10 @@ class Plugin:
|
|||||||
exec(f'self.bot.dbio.{database}=buffer')
|
exec(f'self.bot.dbio.{database}=buffer')
|
||||||
self.bot.db.setlist(database,buffer)
|
self.bot.db.setlist(database,buffer)
|
||||||
self.bot.privmsg("#PalletTown",f'{X}[ {G}added {record} entry to {database} database {X}]')
|
self.bot.privmsg("#PalletTown",f'{X}[ {G}added {record} entry to {database} database {X}]')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def dbentry_remove(self,database,record):
|
def dbentry_remove(self,database,record):
|
||||||
buffer=self.bot.db.getlist(database,[])
|
buffer=self.bot.db.getlist(database,[])
|
||||||
status=False
|
status=False
|
||||||
@ -98,8 +151,10 @@ class Plugin:
|
|||||||
exec(f'self.bot.dbio.{database}=buffer')
|
exec(f'self.bot.dbio.{database}=buffer')
|
||||||
self.bot.db.setlist(database,buffer)
|
self.bot.db.setlist(database,buffer)
|
||||||
self.bot.privmsg("#PalletTown",f'{X}[ {G}removed {record} entry from {database} database - status: {status} {X}]')
|
self.bot.privmsg("#PalletTown",f'{X}[ {G}removed {record} entry from {database} database - status: {status} {X}]')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
async def epochtimestamp(self,timestamp):
|
async def epochtimestamp(self,timestamp):
|
||||||
year,month,day=timestamp.split('T')[0].split('-')
|
year,month,day=timestamp.split('T')[0].split('-')
|
||||||
hour,minute,second=timestamp.split('T')[1].split(':')
|
hour,minute,second=timestamp.split('T')[1].split(':')
|
||||||
@ -107,8 +162,10 @@ class Plugin:
|
|||||||
year,month,day,hour,minute,second,millisecond=[int(x) for x in [year,month,day,hour,minute,second,millisecond]]
|
year,month,day,hour,minute,second,millisecond=[int(x) for x in [year,month,day,hour,minute,second,millisecond]]
|
||||||
epoch_timestamp_past=datetime(year,month,day,hour,minute,second,millisecond).timestamp()
|
epoch_timestamp_past=datetime(year,month,day,hour,minute,second,millisecond).timestamp()
|
||||||
return epoch_timestamp_past
|
return epoch_timestamp_past
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
async def epochdelta(self,timestamp):
|
async def epochdelta(self,timestamp):
|
||||||
year,month,day=timestamp.split('T')[0].split('-')
|
year,month,day=timestamp.split('T')[0].split('-')
|
||||||
hour,minute,second=timestamp.split('T')[1].split(':')
|
hour,minute,second=timestamp.split('T')[1].split(':')
|
||||||
@ -119,29 +176,36 @@ class Plugin:
|
|||||||
epochdelta=epoch_timestamp_present-epoch_timestamp_past
|
epochdelta=epoch_timestamp_present-epoch_timestamp_past
|
||||||
distance=timeago.format(timedelta(seconds=epochdelta),datetime.now())
|
distance=timeago.format(timedelta(seconds=epochdelta),datetime.now())
|
||||||
return distance
|
return distance
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.NEW_NICK)
|
@irc3.event(irc3.rfc.NEW_NICK)
|
||||||
def on_nick_change_for_dsa_hardchatradar(self, nick, new_nick):
|
def on_nick_change_for_dsa_hardchatradar(self, nick, new_nick):
|
||||||
for _ in self.bot.channels.keys():
|
for _ in self.bot.channels.keys():
|
||||||
if _[0]=="#":
|
if _[0]=="#":
|
||||||
USER=str(new_nick).lower()
|
USER=str(new_nick).lower()
|
||||||
self.dsa_hardchatradar(USER,_)
|
self.dsa_hardchatradar(USER,_)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.JOIN)
|
@irc3.event(irc3.rfc.JOIN)
|
||||||
def on_channel_join_for_dsa_hardchatradar(self,mask,channel,**kw):
|
def on_channel_join_for_dsa_hardchatradar(self,mask,channel,**kw):
|
||||||
USER=str(mask.nick).lower
|
USER=str(mask.nick).lower
|
||||||
self.dsa_hardchatradar(mask.nick,channel)
|
self.dsa_hardchatradar(mask.nick,channel)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def dsa_hardchatradar(self, USER, channel):
|
def dsa_hardchatradar(self, USER, channel):
|
||||||
"""radar for hardchatters who join a channel"""
|
"""radar for hardchatters who join a channel"""
|
||||||
###############################################################################
|
|
||||||
###############################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not USER == self.bot.nick:
|
if not USER == self.bot.nick:
|
||||||
#######################################################################
|
|
||||||
self.bot.dbio.LOG=[]
|
self.bot.dbio.LOG=[]
|
||||||
asyncio.set_event_loop(self.bot.loop)
|
asyncio.set_event_loop(self.bot.loop)
|
||||||
asyncio.run_coroutine_threadsafe(self.bot._dsa_scan(USER,channel),self.bot.loop)
|
asyncio.run_coroutine_threadsafe(self.bot._dsa_scan(USER,channel),self.bot.loop)
|
||||||
@ -150,8 +214,10 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa_plugin:hardchat_radar - {e}'
|
msg=f'error: dsa_plugin:hardchat_radar - {e}'
|
||||||
print(msg); #self.bot.privmsg(channel,self.bot.emo(msg))
|
print(msg); #self.bot.privmsg(channel,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def dsa_add_hardchatter(self, mask, target, args):
|
def dsa_add_hardchatter(self, mask, target, args):
|
||||||
"""dsa_add_hardchatter
|
"""dsa_add_hardchatter
|
||||||
@ -177,8 +243,10 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa_plugin:dsa_add_hardchatter > {e}'
|
msg=f'error: dsa_plugin:dsa_add_hardchatter > {e}'
|
||||||
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def dsa_del_hardchatter(self, mask, target, args):
|
def dsa_del_hardchatter(self, mask, target, args):
|
||||||
"""dsa_del_hardchatter
|
"""dsa_del_hardchatter
|
||||||
@ -204,8 +272,10 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa_plugin:dsa_del_hardchatter > {e}'
|
msg=f'error: dsa_plugin:dsa_del_hardchatter > {e}'
|
||||||
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def dsa_list_hardchatters(self, mask, target, args):
|
def dsa_list_hardchatters(self, mask, target, args):
|
||||||
"""dsa_list_hardchatters
|
"""dsa_list_hardchatters
|
||||||
@ -232,8 +302,10 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa_plugin:hardchatters > {e}'
|
msg=f'error: dsa_plugin:hardchatters > {e}'
|
||||||
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def dsa_list_lurkers(self, mask, target, args):
|
def dsa_list_lurkers(self, mask, target, args):
|
||||||
"""dsa_list_lurkers
|
"""dsa_list_lurkers
|
||||||
@ -255,31 +327,34 @@ class Plugin:
|
|||||||
self.bot.privmsg(target, self.bot.emo(_))
|
self.bot.privmsg(target, self.bot.emo(_))
|
||||||
else:
|
else:
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{R}no lurkers"))
|
self.bot.privmsg(target, self.bot.emo(f"{R}no lurkers"))
|
||||||
###########################################################################
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa_plugin:dsa_list_lurkers > {e}'
|
msg=f'error: dsa_plugin:dsa_list_lurkers > {e}'
|
||||||
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); #self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def dsa_analyze(self,mask,target,args):
|
def dsa_analyze(self,mask,target,args):
|
||||||
"""dsa_analyze
|
"""dsa_analyze
|
||||||
%%dsa_analyze <message>...
|
%%dsa_analyze <message>...
|
||||||
"""
|
"""
|
||||||
data=''.join(args['<message>']).strip()
|
data=''.join(args['<message>']).strip()
|
||||||
###################################################################################
|
|
||||||
db_info=self.bot.config['storage']
|
db_info=self.bot.config['storage']
|
||||||
base_dir=f"{os.getcwd()}/{db_info.split('/')[-2]}"
|
base_dir=f"{os.getcwd()}/{db_info.split('/')[-2]}"
|
||||||
db_pathname=f"{base_dir}/{db_info.split('/')[-1]}"
|
db_pathname=f"{base_dir}/{db_info.split('/')[-1]}"
|
||||||
f=open(db_pathname,'r');l=f.read();f.close()
|
f=open(db_pathname,'r');l=f.read();f.close()
|
||||||
###################################################################################
|
|
||||||
db=l.splitlines()
|
db=l.splitlines()
|
||||||
for _ in db:
|
for _ in db:
|
||||||
if not _.find('last_msg_for_')==-1:
|
if not _.find('last_msg_for_')==-1:
|
||||||
self.bot.dbio.seen_users.append(_.split('last_msg_for_')[1].split('"')[0])
|
self.bot.dbio.seen_users.append(_.split('last_msg_for_')[1].split('"')[0])
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
###################################################################################
|
###################################################################################
|
||||||
nicks=[]; key=''; USER=data.lower(); SEARCH_FLAG=False
|
nicks=[]; key=''; USER=data.lower(); SEARCH_FLAG=False
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
key=self.bot.db.getlist(f'last_msg_for_{USER}')
|
key=self.bot.db.getlist(f'last_msg_for_{USER}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -287,10 +362,8 @@ class Plugin:
|
|||||||
if len(USER) > 1:
|
if len(USER) > 1:
|
||||||
if not key:
|
if not key:
|
||||||
SEARCH_FLAG=True
|
SEARCH_FLAG=True
|
||||||
###################################################################################
|
|
||||||
self.bot.dbio.search_users=[]
|
self.bot.dbio.search_users=[]
|
||||||
IS_RUNNING=True
|
IS_RUNNING=True
|
||||||
###################################################################################
|
|
||||||
LOOP=1
|
LOOP=1
|
||||||
if SEARCH_FLAG:
|
if SEARCH_FLAG:
|
||||||
for _ in db:
|
for _ in db:
|
||||||
@ -298,7 +371,6 @@ class Plugin:
|
|||||||
if not _.find(USER)==-1:
|
if not _.find(USER)==-1:
|
||||||
self.bot.dbio.search_users.append(_.split('last_msg_for_')[-1].split('":')[0])
|
self.bot.dbio.search_users.append(_.split('last_msg_for_')[-1].split('":')[0])
|
||||||
LOOP=len(self.bot.dbio.search_users)
|
LOOP=len(self.bot.dbio.search_users)
|
||||||
###################################################################################
|
|
||||||
for i in range(0,LOOP):
|
for i in range(0,LOOP):
|
||||||
if SEARCH_FLAG:
|
if SEARCH_FLAG:
|
||||||
try:
|
try:
|
||||||
@ -308,9 +380,13 @@ class Plugin:
|
|||||||
IS_RUNNING=False
|
IS_RUNNING=False
|
||||||
msg=f"{B}< {R}no {G}{USER} {R}ircnick(s) or similar were found {B}>"
|
msg=f"{B}< {R}no {G}{USER} {R}ircnick(s) or similar were found {B}>"
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
newnicks=0; privmsgs=0; lastmsg=[]; lasttime=[]
|
newnicks=0; privmsgs=0; lastmsg=[]; lasttime=[]
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for _ in key:
|
for _ in key:
|
||||||
if _['type']=='newnick':
|
if _['type']=='newnick':
|
||||||
@ -321,17 +397,13 @@ class Plugin:
|
|||||||
lasttime.append(_['time'])
|
lasttime.append(_['time'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'error: dsa:nicks:search -> no items of a key means no db operation: {e}')
|
print(f'error: dsa:nicks:search -> no items of a key means no db operation: {e}')
|
||||||
###############################################################################
|
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
###############################################################################
|
|
||||||
if newnicks>0 or privmsgs>0:
|
if newnicks>0 or privmsgs>0:
|
||||||
self.bot.privmsg("#PalletTown",f"{D}<<< {G}{USER} {B}- {G}ircnicks{B}: {D}{int(newnicks)+1} {B}- {G}messages{B}: {G}{privmsgs} {D}>>>")
|
self.bot.privmsg("#PalletTown",f"{D}<<< {G}{USER} {B}- {G}ircnicks{B}: {D}{int(newnicks)+1} {B}- {G}messages{B}: {G}{privmsgs} {D}>>>")
|
||||||
###############################################################################
|
|
||||||
if privmsgs>0:
|
if privmsgs>0:
|
||||||
for i in range(0,privmsgs):
|
for i in range(0,privmsgs):
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
self.bot.privmsg("#PalletTown",f'{G}{lasttime[i]} {B}> {R}{USER} {B}> {D}{lastmsg[i]}')
|
self.bot.privmsg("#PalletTown",f'{G}{lasttime[i]} {B}> {R}{USER} {B}> {D}{lastmsg[i]}')
|
||||||
###############################################################################
|
|
||||||
if newnicks==0:
|
if newnicks==0:
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}');
|
self.bot.privmsg("#PalletTown",f'{"#"*69}');
|
||||||
self.bot.privmsg("#PalletTown",f"!!! no alternate ircnicks !!!")
|
self.bot.privmsg("#PalletTown",f"!!! no alternate ircnicks !!!")
|
||||||
@ -342,43 +414,33 @@ class Plugin:
|
|||||||
elif i==LOOP and SEARCH_FLAG:
|
elif i==LOOP and SEARCH_FLAG:
|
||||||
IS_RUNNING=False
|
IS_RUNNING=False
|
||||||
return
|
return
|
||||||
###############################################################################
|
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
###############################################################################
|
|
||||||
while IS_RUNNING:
|
while IS_RUNNING:
|
||||||
###########################################################################
|
|
||||||
if not SEARCH_FLAG:
|
if not SEARCH_FLAG:
|
||||||
msg=f"{D}<<< {R}near region{D} >>>"
|
msg=f"{D}<<< {R}near region{D} >>>"
|
||||||
else:
|
else:
|
||||||
msg=f"{D}<<< {R}near region - issues{D} >>>"
|
msg=f"{D}<<< {R}near region - issues{D} >>>"
|
||||||
self.bot.privmsg("#PalletTown",msg); self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",msg); self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
###########################################################################
|
|
||||||
for _ in key:
|
for _ in key:
|
||||||
if _['type']=='newnick':
|
if _['type']=='newnick':
|
||||||
f,t=_['msg'].split(' changed nick to ')
|
f,t=_['msg'].split(' changed nick to ')
|
||||||
self.bot.privmsg("#PalletTown",f'{D}{_["time"]} {B}> {R}from ircnick {G}{f} {R}to ircnick {G}{t}')
|
self.bot.privmsg("#PalletTown",f'{D}{_["time"]} {B}> {R}from ircnick {G}{f} {R}to ircnick {G}{t}')
|
||||||
nicks.append(f)
|
nicks.append(f)
|
||||||
###########################################################################
|
|
||||||
nicks=list(set(nicks))
|
nicks=list(set(nicks))
|
||||||
###########################################################################
|
|
||||||
if len(nicks)>0:
|
if len(nicks)>0:
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
#######################################################################
|
|
||||||
if not SEARCH_FLAG:
|
if not SEARCH_FLAG:
|
||||||
msg=f'{D}[ {G}{USER} {D}- {R}alternate ircnicks - direct referfence{D}]{B}: {R}{" ".join(nicks)}'
|
msg=f'{D}[ {G}{USER} {D}- {R}alternate ircnicks - direct reference{D}]{B}: {R}{" ".join(nicks)}'
|
||||||
else:
|
else:
|
||||||
msg=f'{D}[ {G}{USER} {D}- {R}alternate ircnicks - keyworded{D}]{B}: {R}{" ".join(nicks)}'
|
msg=f'{D}[ {G}{USER} {D}- {R}alternate ircnicks - keyworded{D}]{B}: {R}{" ".join(nicks)}'
|
||||||
###########################################################################
|
|
||||||
self.bot.privmsg("#PalletTown",msg); self.bot.privmsg("#PalletTown",f'{"#"*69}'); self.bot.privmsg("#PalletTown",f"{D}<<< {R}distant region{D} >>>"); self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",msg); self.bot.privmsg("#PalletTown",f'{"#"*69}'); self.bot.privmsg("#PalletTown",f"{D}<<< {R}distant region{D} >>>"); self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
for _ in nicks:
|
for _ in nicks:
|
||||||
self.bot.privmsg("#PalletTown",f'{B}[ {R}{_} {B}]')
|
self.bot.privmsg("#PalletTown",f'{B}[ {R}{_} {B}]')
|
||||||
try:
|
try:
|
||||||
key=self.bot.db.getlist(f'last_msg_for_{_}')
|
key=self.bot.db.getlist(f'last_msg_for_{_}')
|
||||||
for __ in key:
|
for __ in key:
|
||||||
###############################################################
|
|
||||||
if __['type']=='privmsg':
|
if __['type']=='privmsg':
|
||||||
self.bot.privmsg("#PalletTown",f'{D}{__["time"]} {B}> {R}{_} {B}> {D}{__["msg"]}"')
|
self.bot.privmsg("#PalletTown",f'{D}{__["time"]} {B}> {R}{_} {B}> {D}{__["msg"]}"')
|
||||||
###############################################################
|
|
||||||
elif __['type']=='newnick':
|
elif __['type']=='newnick':
|
||||||
f,t=__['msg'].split(' changed nick to ')
|
f,t=__['msg'].split(' changed nick to ')
|
||||||
self.bot.privmsg("#PalletTown",f'{D}{__["time"]} {B}> {R}to ircnick {B}{t} {R}from ircnick {G}{f}')
|
self.bot.privmsg("#PalletTown",f'{D}{__["time"]} {B}> {R}to ircnick {B}{t} {R}from ircnick {G}{f}')
|
||||||
@ -399,11 +461,9 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
IS_OK=False
|
IS_OK=False
|
||||||
print(f'error: dsa:dirties:IS_OK -> pulling db key for last_msg_for_{f}: {e}')
|
print(f'error: dsa:dirties:IS_OK -> pulling db key for last_msg_for_{f}: {e}')
|
||||||
###############################################################
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.bot.privmsg("#PalletTown",f'{D}<{R}none{D}>')
|
self.bot.privmsg("#PalletTown",f'{D}<{R}none{D}>')
|
||||||
print(f'error: dsa:dirties -> pulling db key for last_msg_for_{_}: {e}')
|
print(f'error: dsa:dirties -> pulling db key for last_msg_for_{_}: {e}')
|
||||||
###########################################################################
|
|
||||||
if SEARCH_FLAG:
|
if SEARCH_FLAG:
|
||||||
self.bot.privmsg("#PalletTown",f'{B}<<< {R}total instances found{X}: {R}{LOOP} {B}>>>')
|
self.bot.privmsg("#PalletTown",f'{B}<<< {R}total instances found{X}: {R}{LOOP} {B}>>>')
|
||||||
#self.log_play(target)
|
#self.log_play(target)
|
||||||
@ -416,11 +476,16 @@ class Plugin:
|
|||||||
IS_RUNNING=False
|
IS_RUNNING=False
|
||||||
else:
|
else:
|
||||||
IS_RUNNING=False
|
IS_RUNNING=False
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
async def _dsa_scan(self,NICK,target):
|
async def _dsa_scan(self,NICK,target):
|
||||||
###############################################################################
|
|
||||||
###############################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}');
|
self.bot.privmsg("#PalletTown",f'{"#"*69}');
|
||||||
msg=f'{G}<<< {S}analyzing {NICK} {G}>>>'
|
msg=f'{G}<<< {S}analyzing {NICK} {G}>>>'
|
||||||
self.bot.privmsg("#PalletTown",msg)
|
self.bot.privmsg("#PalletTown",msg)
|
||||||
@ -459,8 +524,6 @@ class Plugin:
|
|||||||
cmd=f"MODE {target} +v {USER}"
|
cmd=f"MODE {target} +v {USER}"
|
||||||
self.bot.send(cmd)
|
self.bot.send(cmd)
|
||||||
else:
|
else:
|
||||||
###################################################################
|
|
||||||
###################################################################
|
|
||||||
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
self.bot.privmsg("#PalletTown",f'{"#"*69}')
|
||||||
records=len(key)
|
records=len(key)
|
||||||
records_timestamps=[]
|
records_timestamps=[]
|
||||||
@ -501,8 +564,6 @@ class Plugin:
|
|||||||
timestamp=await self.epochdelta(_key['time'])
|
timestamp=await self.epochdelta(_key['time'])
|
||||||
records_timestamps.append(_key['time'])
|
records_timestamps.append(_key['time'])
|
||||||
records_newnicks.append(timestamp)
|
records_newnicks.append(timestamp)
|
||||||
###################################################################
|
|
||||||
###################################################################
|
|
||||||
records_timestamps.sort()
|
records_timestamps.sort()
|
||||||
faded_timestamp=await self.epochtimestamp(records_timestamps[-1])
|
faded_timestamp=await self.epochtimestamp(records_timestamps[-1])
|
||||||
newest_timestamp=await self.epochdelta(records_timestamps[-1])
|
newest_timestamp=await self.epochdelta(records_timestamps[-1])
|
||||||
@ -510,8 +571,6 @@ class Plugin:
|
|||||||
oldest_timestamp=await self.epochdelta(records_timestamps[-1])
|
oldest_timestamp=await self.epochdelta(records_timestamps[-1])
|
||||||
oldest_timestamp_epoch=await self.epochtimestamp(records_timestamps[-1])
|
oldest_timestamp_epoch=await self.epochtimestamp(records_timestamps[-1])
|
||||||
history_timestamp=datetime.now().timestamp()-oldest_timestamp_epoch
|
history_timestamp=datetime.now().timestamp()-oldest_timestamp_epoch
|
||||||
###################################################################
|
|
||||||
###################################################################
|
|
||||||
faded_status=False
|
faded_status=False
|
||||||
idle_status=False
|
idle_status=False
|
||||||
idler_status=False
|
idler_status=False
|
||||||
@ -533,8 +592,6 @@ class Plugin:
|
|||||||
hardchat_status=True
|
hardchat_status=True
|
||||||
if USER in self.bot.dbio.lurkers:
|
if USER in self.bot.dbio.lurkers:
|
||||||
lurker_status=True
|
lurker_status=True
|
||||||
###################################################################
|
|
||||||
###################################################################
|
|
||||||
if records_privmsgs==0:
|
if records_privmsgs==0:
|
||||||
self.dbentry_add('lurkers',USER)
|
self.dbentry_add('lurkers',USER)
|
||||||
lurker_status=True
|
lurker_status=True
|
||||||
@ -619,15 +676,14 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa_plugin:hardchattting > {e}'
|
msg=f'error: dsa_plugin:hardchattting > {e}'
|
||||||
self.bot.privmsg("#PalletTown",msg)
|
self.bot.privmsg("#PalletTown",msg)
|
||||||
#######################################################################
|
|
||||||
#######################################################################
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'error: dsa:lurkers > {e}'
|
msg=f'error: dsa:lurkers > {e}'
|
||||||
print(msg)
|
print(msg)
|
||||||
self.bot.privmsg("#PalletTown",msg)
|
self.bot.privmsg("#PalletTown",msg)
|
||||||
###############################################################################
|
|
||||||
###############################################################################
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def dsa_scan(self,mask,target,args):
|
def dsa_scan(self,mask,target,args):
|
||||||
@ -650,8 +706,6 @@ class Plugin:
|
|||||||
if OP_FLAG:
|
if OP_FLAG:
|
||||||
msg=f'{G}<<< {S}analyzing {CHANNEL} users {G}>>>'
|
msg=f'{G}<<< {S}analyzing {CHANNEL} users {G}>>>'
|
||||||
self.bot.privmsg("#PalletTown",msg)
|
self.bot.privmsg("#PalletTown",msg)
|
||||||
###############################################################################
|
|
||||||
###############################################################################
|
|
||||||
if not target in self.bot.dbio.channel:
|
if not target in self.bot.dbio.channel:
|
||||||
self.bot.dbio.channel.append(target)
|
self.bot.dbio.channel.append(target)
|
||||||
self.bot.dbio.channel_users.append(channel)
|
self.bot.dbio.channel_users.append(channel)
|
||||||
@ -665,62 +719,54 @@ class Plugin:
|
|||||||
asyncio.run_coroutine_threadsafe(asyncio.sleep(0.5),self.bot.loop)
|
asyncio.run_coroutine_threadsafe(asyncio.sleep(0.5),self.bot.loop)
|
||||||
# while len(self.bot.dbio.LOG) > 0:
|
# while len(self.bot.dbio.LOG) > 0:
|
||||||
# self.bot.log_play("#pallettown")
|
# self.bot.log_play("#pallettown")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=True)
|
@command(permission='admin', public=True, show_in_help_list=True)
|
||||||
def dsa_set_threshold_history(self,mask,target,args):
|
def dsa_set_threshold_history(self,mask,target,args):
|
||||||
"""dsa_set_threshold_history - sets a threshold by distance in days - if there is no record within that amount of time then they fall below this threshold and will be marked with no history, this is used to indicate if a user is a rando or a known user. default value is 30 days. 90 day threshold example: ?dsa_set_threshold_history 90
|
"""dsa_set_threshold_history - sets a threshold by distance in days - if there is no record within that amount of time then they fall below this threshold and will be marked with no history, this is used to indicate if a user is a rando or a known user. default value is 30 days. 90 day threshold example: ?dsa_set_threshold_history 90
|
||||||
%%dsa_set_threshold_history <message>...
|
%%dsa_set_threshold_history <message>...
|
||||||
"""
|
"""
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
data=''.join(args['<message>']).strip()
|
data=''.join(args['<message>']).strip()
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
try:
|
try:
|
||||||
self.bot.dbio.history_threshold=int(data)
|
self.bot.dbio.history_threshold=int(data)
|
||||||
msg=f'{R}{mask.nick}{B}: {R}dsa_plugin:dsa_history_threshold set to {B}{data} days'
|
msg=f'{R}{mask.nick}{B}: {R}dsa_plugin:dsa_history_threshold set to {B}{data} days'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'{mask.nick}: error - dsa_plugin:dsa_history_threshold > {e}'
|
msg=f'{mask.nick}: error - dsa_plugin:dsa_history_threshold > {e}'
|
||||||
print(msg); self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=True)
|
@command(permission='admin', public=True, show_in_help_list=True)
|
||||||
def dsa_set_threshold_faded(self,mask,target,args):
|
def dsa_set_threshold_faded(self,mask,target,args):
|
||||||
"""dsa_set_threshold_faded - sets a threshold by distance in days to mark a user awol - if there is no record within that amount of time then they fall below this threshold and will be marked awol. default value is 14 days. 90 day threshold example: ?dsa_set_threshold_faded 90
|
"""dsa_set_threshold_faded - sets a threshold by distance in days to mark a user awol - if there is no record within that amount of time then they fall below this threshold and will be marked awol. default value is 14 days. 90 day threshold example: ?dsa_set_threshold_faded 90
|
||||||
%%dsa_set_threshold_faded <message>...
|
%%dsa_set_threshold_faded <message>...
|
||||||
"""
|
"""
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
data=''.join(args['<message>']).strip()
|
data=''.join(args['<message>']).strip()
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
try:
|
try:
|
||||||
self.bot.dbio.faded_threshold=int(data)
|
self.bot.dbio.faded_threshold=int(data)
|
||||||
msg=f'{R}{mask.nick}{B}: {R}dsa_plugin:dsa_faded_threshold set to {B}{data} days'
|
msg=f'{R}{mask.nick}{B}: {R}dsa_plugin:dsa_faded_threshold set to {B}{data} days'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'{mask.nick}: error - dsa_plugin:dsa_faded_threshold > {e}'
|
msg=f'{mask.nick}: error - dsa_plugin:dsa_faded_threshold > {e}'
|
||||||
print(msg); self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=True)
|
@command(permission='admin', public=True, show_in_help_list=True)
|
||||||
def dsa_set_threshold_idle(self,mask,target,args):
|
def dsa_set_threshold_idle(self,mask,target,args):
|
||||||
"""dsa_set_threshold_idle - sets a threshold by distance in hours - if there is no record within that amount of time then they fall below this threshold and will be marked idle. default value is 1 hour. 3 hour threshold example: ?dsa_set_threshold_idle 3
|
"""dsa_set_threshold_idle - sets a threshold by distance in hours - if there is no record within that amount of time then they fall below this threshold and will be marked idle. default value is 1 hour. 3 hour threshold example: ?dsa_set_threshold_idle 3
|
||||||
%%dsa_set_threshold_idle <message>...
|
%%dsa_set_threshold_idle <message>...
|
||||||
"""
|
"""
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
data=''.join(args['<message>']).strip()
|
data=''.join(args['<message>']).strip()
|
||||||
###################################################################################
|
|
||||||
###################################################################################
|
|
||||||
try:
|
try:
|
||||||
self.bot.dbio.history_threshold=int(data)
|
self.bot.dbio.history_threshold=int(data)
|
||||||
msg=f'{R}{mask.nick}{B}: {R}dsa_plugin:dsa_history_threshold set to {B}{data} days'
|
msg=f'{R}{mask.nick}{B}: {R}dsa_plugin:dsa_history_threshold set to {B}{data} days'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f'{mask.nick}: error - dsa_plugin:dsa_history_threshold > {e}'
|
msg=f'{mask.nick}: error - dsa_plugin:dsa_history_threshold > {e}'
|
||||||
print(msg); self.bot.privmsg(target,self.bot.emo(msg))
|
print(msg); self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
#### EOF CLASS INSTANCE EOF CLASS INSTANCE EOF CLASS INSTANCE EOF CLASS INSTANCE
|
|
||||||
#### EOF CLASS INSTANCE EOF CLASS INSTANCE EOF CLASS INSTANCE EOF CLASS INSTANCE
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def emo(self,s):
|
def emo(self,s):
|
||||||
emote_db = '%s/../databases/emote.db' % dir_path
|
emote_db = '%s/../databases/emote.db' % dir_path
|
||||||
@ -25,8 +37,10 @@ class Plugin:
|
|||||||
emoj = "\x0303{}\x0F".format(emoj)
|
emoj = "\x0303{}\x0F".format(emoj)
|
||||||
s = s + '\x0303 > ' + emoj
|
s = s + '\x0303 > ' + emoj
|
||||||
return s
|
return s
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view',show_in_help_list=False)
|
@command(permission='view',show_in_help_list=False)
|
||||||
def emote(self, mask, target, args):
|
def emote(self, mask, target, args):
|
||||||
"""Show Emotion
|
"""Show Emotion
|
||||||
@ -37,6 +51,6 @@ class Plugin:
|
|||||||
return random.choice(list(open(emote_db)))
|
return random.choice(list(open(emote_db)))
|
||||||
emoj = __random_line()
|
emoj = __random_line()
|
||||||
self.bot.privmsg(target, "%s" % emoj)
|
self.bot.privmsg(target, "%s" % emoj)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,14 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import irc3
|
import irc3
|
||||||
from stat import S_ISFIFO
|
from stat import S_ISFIFO
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Fifo:
|
class Fifo:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
BLOCK_SIZE = 1024
|
BLOCK_SIZE = 1024
|
||||||
MAX_BUFFER_SIZE = 800
|
MAX_BUFFER_SIZE = 800
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
self.config = self.context.config
|
self.config = self.context.config
|
||||||
@ -20,7 +32,10 @@ class Fifo:
|
|||||||
self.fifos = {}
|
self.fifos = {}
|
||||||
self.buffers = {}
|
self.buffers = {}
|
||||||
self.create_fifo(None)
|
self.create_fifo(None)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def read_fd(cls, fd):
|
def read_fd(cls, fd):
|
||||||
while True:
|
while True:
|
||||||
@ -30,7 +45,10 @@ class Fifo:
|
|||||||
continue
|
continue
|
||||||
except BlockingIOError:
|
except BlockingIOError:
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def handle_line(self, line, channel):
|
def handle_line(self, line, channel):
|
||||||
if not line:
|
if not line:
|
||||||
return
|
return
|
||||||
@ -41,7 +59,10 @@ class Fifo:
|
|||||||
self.context.send_line(line)
|
self.context.send_line(line)
|
||||||
else:
|
else:
|
||||||
self.context.privmsg(channel, line)
|
self.context.privmsg(channel, line)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def data_received(self, data, channel):
|
def data_received(self, data, channel):
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
@ -61,7 +82,10 @@ class Fifo:
|
|||||||
self.buffers[channel] = b""
|
self.buffers[channel] = b""
|
||||||
else:
|
else:
|
||||||
self.buffers[channel] = last
|
self.buffers[channel] = last
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def watch_fd(self, fd, channel):
|
def watch_fd(self, fd, channel):
|
||||||
reading = True
|
reading = True
|
||||||
|
|
||||||
@ -69,7 +93,10 @@ class Fifo:
|
|||||||
data = self.read_fd(fd)
|
data = self.read_fd(fd)
|
||||||
reading = len(data) == self.BLOCK_SIZE
|
reading = len(data) == self.BLOCK_SIZE
|
||||||
self.data_received(data, channel)
|
self.data_received(data, channel)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def create_fifo(self, channel):
|
def create_fifo(self, channel):
|
||||||
if channel is None:
|
if channel is None:
|
||||||
path = os.path.join(self.runpath, ':raw')
|
path = os.path.join(self.runpath, ':raw')
|
||||||
@ -89,14 +116,17 @@ class Fifo:
|
|||||||
os.mkfifo(path)
|
os.mkfifo(path)
|
||||||
fd = os.open(path, os.O_RDWR | os.O_NONBLOCK)
|
fd = os.open(path, os.O_RDWR | os.O_NONBLOCK)
|
||||||
self.loop.add_reader(fd, self.watch_fd, fd, channel)
|
self.loop.add_reader(fd, self.watch_fd, fd, channel)
|
||||||
self.context.log.debug("%s's fifo is %s %r",
|
self.context.log.debug("%s's fifo is %s %r",channel or ':raw', path, fd)
|
||||||
channel or ':raw', path, fd)
|
|
||||||
return fd
|
return fd
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.JOIN)
|
@irc3.event(irc3.rfc.JOIN)
|
||||||
def join(self, mask=None, channel=None, **kwargs):
|
def join(self, mask=None, channel=None, **kwargs):
|
||||||
if mask.nick == self.context.nick:
|
if mask.nick == self.context.nick:
|
||||||
if channel not in self.fifos:
|
if channel not in self.fifos:
|
||||||
self.fifos[channel] = self.create_fifo(channel)
|
self.fifos[channel] = self.create_fifo(channel)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,21 +1,35 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import pyfiglet
|
import pyfiglet
|
||||||
import random
|
import random
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
fig = pyfiglet.Figlet(width=100)
|
fig = pyfiglet.Figlet(width=100)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.fig_fonts = set(self.bot.db.getlist("fig_font_list", []))
|
self.fig_fonts = set(self.bot.db.getlist("fig_font_list", []))
|
||||||
if not self.fig_fonts:
|
if not self.fig_fonts:
|
||||||
self.fig_fonts = ['poison','isometric2', 'puffy', 'standard', 'nancyj-fancy', 'chunky', 'broadway', 'cosmike', 'mirror', 'gradient', 'banner3-D', 'isometric4', 'ogre', 'smisome1', 'starwars', 'lean', 'whimsy', 'dotmatrix', 'cricket', 'isometric1', 'caligraphy', 'pawp', 'univers', 'cosmic', 'graceful', 'thin', 'rozzo', 'defleppard', 'marquee', 'rowancap', 'stop', 'shimrod', 'fuzzy', 'coinstak', 'fraktur', 'shadow', 'doh', 'charact1', 'big', 'roman', 'rev', 'cybersmall', 'rounded', 'stacey', 'ascii___', 'nancyj', 'smslant', 'doom']
|
self.fig_fonts = ['poison','isometric2', 'puffy', 'standard', 'nancyj-fancy', 'chunky', 'broadway', 'cosmike', 'mirror', 'gradient', 'banner3-D', 'isometric4', 'ogre', 'smisome1', 'starwars', 'lean', 'whimsy', 'dotmatrix', 'cricket', 'isometric1', 'caligraphy', 'pawp', 'univers', 'cosmic', 'graceful', 'thin', 'rozzo', 'defleppard', 'marquee', 'rowancap', 'stop', 'shimrod', 'fuzzy', 'coinstak', 'fraktur', 'shadow', 'doh', 'charact1', 'big', 'roman', 'rev', 'cybersmall', 'rounded', 'stacey', 'ascii___', 'nancyj', 'smslant', 'doom']
|
||||||
self.bot.db.setlist("fig_font_list", self.fig_fonts)
|
self.bot.db.setlist("fig_font_list", self.fig_fonts)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def fig(self, text=None, font=None, width=None):
|
def fig(self, text=None, font=None, width=None):
|
||||||
if font in self.fig_fonts:
|
if font in self.fig_fonts:
|
||||||
@ -26,7 +40,10 @@ class Plugin:
|
|||||||
fig.width=width
|
fig.width=width
|
||||||
if not text: return
|
if not text: return
|
||||||
return fig.renderText(text)
|
return fig.renderText(text)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view', name="fig", public=True, show_in_help_list=True)
|
@command(permission='view', name="fig", public=True, show_in_help_list=True)
|
||||||
def figcmd(self, mask, target, args):
|
def figcmd(self, mask, target, args):
|
||||||
"""Print figlet Text
|
"""Print figlet Text
|
||||||
@ -77,11 +94,9 @@ class Plugin:
|
|||||||
newfont = random.choice(list(self.fig_fonts))
|
newfont = random.choice(list(self.fig_fonts))
|
||||||
msg = self.bot.emo(newfont)
|
msg = self.bot.emo(newfont)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
fig_text = self.fig(text=text, font=newfont, width=width) # Cause weird command format
|
fig_text = self.fig(text=text, font=newfont, width=width)
|
||||||
for line in fig_text.split("\n"):
|
for line in fig_text.split("\n"):
|
||||||
self.bot.privmsg(target, line)
|
self.bot.privmsg(target, line)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
#
|
|
||||||
# MY PREFERENCE OF FONTS TO REMOVE FROM OPTIONS LIST
|
|
||||||
#
|
|
||||||
|
@ -1,20 +1,34 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from lxml.html import fromstring
|
from lxml.html import fromstring
|
||||||
from googlesearch import search
|
from googlesearch import search
|
||||||
import irc3,os,sys,requests
|
import irc3,os,sys,requests
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __get_tiny_url(self, url):
|
def __get_tiny_url(self, url):
|
||||||
tiny_url = 'http://tinyurl.com/api-create.php?url=%s' % url
|
tiny_url = 'http://tinyurl.com/api-create.php?url=%s' % url
|
||||||
r = requests.get(tiny_url)
|
r = requests.get(tiny_url)
|
||||||
return r.text
|
return r.text
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view', public=True, show_in_help_list=True)
|
@command(permission='view', public=True, show_in_help_list=True)
|
||||||
def g(self, mask, target, args):
|
def g(self, mask, target, args):
|
||||||
"""Google Query
|
"""Google Query
|
||||||
@ -52,5 +66,6 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("%s" % e)
|
print("%s" % e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __color(self,c):
|
def __color(self,c):
|
||||||
try:
|
try:
|
||||||
c=str(c.lower())
|
c=str(c.lower())
|
||||||
@ -37,8 +47,10 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
print('_color: error')
|
print('_color: error')
|
||||||
return '\x0f'
|
return '\x0f'
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view',public=True,show_in_help_list=True)
|
@command(permission='view',public=True,show_in_help_list=True)
|
||||||
def hl(self, mask, target, args):
|
def hl(self, mask, target, args):
|
||||||
"""hl - use a chosen or random color palette that will iterate a message to whichever ircnick you pick.
|
"""hl - use a chosen or random color palette that will iterate a message to whichever ircnick you pick.
|
||||||
@ -48,7 +60,6 @@ class Plugin:
|
|||||||
uses a random color palette, tags ircnick dr1p with hello message 1 time. example 3: ?hl dr1p hello.
|
uses a random color palette, tags ircnick dr1p with hello message 1 time. example 3: ?hl dr1p hello.
|
||||||
%%hl <message>...
|
%%hl <message>...
|
||||||
"""
|
"""
|
||||||
###################################################################################
|
|
||||||
try:
|
try:
|
||||||
message=' '.join(args['<message>']).strip()
|
message=' '.join(args['<message>']).strip()
|
||||||
channel=self.bot.channels[target]
|
channel=self.bot.channels[target]
|
||||||
@ -64,7 +75,6 @@ class Plugin:
|
|||||||
GOT_PALETTE=''; palette=''
|
GOT_PALETTE=''; palette=''
|
||||||
GOT_IRCNICK=''; ircnick=mask.nick
|
GOT_IRCNICK=''; ircnick=mask.nick
|
||||||
GOT_ITERATIONS=''; iterations=1
|
GOT_ITERATIONS=''; iterations=1
|
||||||
###############################################################################
|
|
||||||
for palette in message.split():
|
for palette in message.split():
|
||||||
try:
|
try:
|
||||||
if len(palette.split(','))==10:
|
if len(palette.split(','))==10:
|
||||||
@ -72,7 +82,6 @@ class Plugin:
|
|||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
for ircnick in message.split():
|
for ircnick in message.split():
|
||||||
try:
|
try:
|
||||||
if ircnick in channel:
|
if ircnick in channel:
|
||||||
@ -80,7 +89,6 @@ class Plugin:
|
|||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
for iterations in message.split():
|
for iterations in message.split():
|
||||||
try:
|
try:
|
||||||
if int(iterations)>0:
|
if int(iterations)>0:
|
||||||
@ -88,7 +96,6 @@ class Plugin:
|
|||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
###############################################################################
|
|
||||||
if GOT_IRCNICK:
|
if GOT_IRCNICK:
|
||||||
message=message.replace(GOT_IRCNICK,'')
|
message=message.replace(GOT_IRCNICK,'')
|
||||||
ircnick=GOT_IRCNICK
|
ircnick=GOT_IRCNICK
|
||||||
@ -110,7 +117,6 @@ class Plugin:
|
|||||||
iterations=GOT_ITERATIONS
|
iterations=GOT_ITERATIONS
|
||||||
else:
|
else:
|
||||||
iterations=1
|
iterations=1
|
||||||
###############################################################################
|
|
||||||
message=message.strip()
|
message=message.strip()
|
||||||
for i in range(int(iterations)):
|
for i in range(int(iterations)):
|
||||||
h1=self.__color(hex(c1)[2:])
|
h1=self.__color(hex(c1)[2:])
|
||||||
@ -120,10 +126,9 @@ class Plugin:
|
|||||||
msg=f'{h1}{s1[0]} {h2}{ircnick} {h1}{s1[1]} {h3}{s2[0]} {h4}{message} {h3}{s2[1]} {h1}{s1[0]} {h2}{ircnick} {h1}{s1[1]}\x20'
|
msg=f'{h1}{s1[0]} {h2}{ircnick} {h1}{s1[1]} {h3}{s2[0]} {h4}{message} {h3}{s2[1]} {h1}{s1[0]} {h2}{ircnick} {h1}{s1[1]}\x20'
|
||||||
if not GOT_PALETTE: msg+=f"{h1}{str(c1).zfill(2)},{h2}{str(c2).zfill(2)},{h3}{str(c3).zfill(2)},{h4}{str(c4).zfill(2)},{h1}{str(n1[0]).zfill(2)},{str(n1[1]).zfill(2)},{str(n1[2]).zfill(2)},{h3}{str(n2[0]).zfill(2)},{str(n2[1]).zfill(2)},{str(n2[2]).zfill(2)}"
|
if not GOT_PALETTE: msg+=f"{h1}{str(c1).zfill(2)},{h2}{str(c2).zfill(2)},{h3}{str(c3).zfill(2)},{h4}{str(c4).zfill(2)},{h1}{str(n1[0]).zfill(2)},{str(n1[1]).zfill(2)},{str(n1[2]).zfill(2)},{h3}{str(n2[0]).zfill(2)},{str(n2[1]).zfill(2)},{str(n2[2]).zfill(2)}"
|
||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
###############################################################################
|
|
||||||
###################################################################################
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg=f"{mask.nick}: highlight_plugin:hl - error: {e}"
|
msg=f"{mask.nick}: highlight_plugin:hl - error: {e}"
|
||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
58
storage/bot/plugins/ip_plugin.py
Normal file
58
storage/bot/plugins/ip_plugin.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
from irc3.plugins.command import command
|
||||||
|
import irc3
|
||||||
|
import requests
|
||||||
|
import socket
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
@irc3.plugin
|
||||||
|
class Plugin:
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def reload(cls, old):
|
||||||
|
return cls(old.bot)
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
def before_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
def after_reload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
@command(permission='view')
|
||||||
|
def ip(self, mask, target, args):
|
||||||
|
"""Show ip info
|
||||||
|
%%ip <ip>
|
||||||
|
"""
|
||||||
|
ip = args.get('<ip>')
|
||||||
|
try:
|
||||||
|
ip = socket.gethostbyname(ip)
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
msg = "ip: {IP}"
|
||||||
|
msg = msg.format(IP=ip)
|
||||||
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
@ -1,18 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def isup_check(self, domain_or_ip):
|
def isup_check(self, domain_or_ip):
|
||||||
msg=''
|
msg=''
|
||||||
try:
|
try:
|
||||||
@ -51,8 +59,10 @@ class Plugin:
|
|||||||
msg=f'up -> https://{domain_or_ip} is communicating'
|
msg=f'up -> https://{domain_or_ip} is communicating'
|
||||||
finally:
|
finally:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def isup(self, mask, target, args):
|
def isup(self, mask, target, args):
|
||||||
"""isup domain
|
"""isup domain
|
||||||
@ -81,5 +91,6 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,self.bot.emo("{}: doesn't sanitize towards a valid domain/ip".format(domain)))
|
self.bot.privmsg(target,self.bot.emo("{}: doesn't sanitize towards a valid domain/ip".format(domain)))
|
||||||
return
|
return
|
||||||
self.bot.privmsg(target,self.bot.emo("{}".format(self.isup_check(domain))))
|
self.bot.privmsg(target,self.bot.emo("{}".format(self.isup_check(domain))))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,21 +1,27 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
###########################################################################################
|
|
||||||
###########################################################################################
|
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
self.site_url="https://icanhazdadjoke.com"
|
self.site_url="https://icanhazdadjoke.com"
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def urlget(self,url):
|
def urlget(self,url):
|
||||||
USER_AGENT_CURL="curl/7.78.0"
|
USER_AGENT_CURL="curl/7.78.0"
|
||||||
ACCEPT_MODES="text/plain"
|
ACCEPT_MODES="text/plain"
|
||||||
@ -27,8 +33,10 @@ class Plugin:
|
|||||||
except HTTPError as e: return STATUS_BAD_CODE.format(e.code)
|
except HTTPError as e: return STATUS_BAD_CODE.format(e.code)
|
||||||
except URLError as e: return STATUS_BAD_REASON.format(e.reason)
|
except URLError as e: return STATUS_BAD_REASON.format(e.reason)
|
||||||
else: return STATUS_OK + response
|
else: return STATUS_OK + response
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def joke(self, mask, target, args):
|
def joke(self, mask, target, args):
|
||||||
@ -39,5 +47,6 @@ class Plugin:
|
|||||||
for msg in response.splitlines():
|
for msg in response.splitlines():
|
||||||
if len(msg) > 1:
|
if len(msg) > 1:
|
||||||
self.bot.privmsg(target, self.bot.emo(msg))
|
self.bot.privmsg(target, self.bot.emo(msg))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import configparser
|
import configparser
|
||||||
import io
|
import io
|
||||||
@ -10,7 +12,16 @@ from difflib import SequenceMatcher
|
|||||||
from glob import glob
|
from glob import glob
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
import sklearn
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import requests
|
import requests
|
||||||
import torch
|
import torch
|
||||||
@ -19,53 +30,73 @@ from tqdm import tqdm
|
|||||||
from transformers import GPT2Config, GPT2LMHeadModel, GPT2Tokenizer
|
from transformers import GPT2Config, GPT2LMHeadModel, GPT2Tokenizer
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
global message_history
|
global message_history
|
||||||
class MESSAGE_HISTORY():
|
class MESSAGE_HISTORY():
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
maple_messages = []
|
maple_messages = []
|
||||||
user_messages = []
|
user_messages = []
|
||||||
user_users = []
|
user_users = []
|
||||||
last_message = ''
|
last_message = ''
|
||||||
maple_message = ''
|
maple_message = ''
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.processing=0
|
self.processing=0
|
||||||
self.bounce=False
|
self.bounce=False
|
||||||
self.loopcount=0
|
self.loopcount=0
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push_maple_messages(self,data):
|
def push_maple_messages(self,data):
|
||||||
self.maple_messages = self.maple_messages[-1:] + self.maple_messages[:-1]
|
self.maple_messages = self.maple_messages[-1:] + self.maple_messages[:-1]
|
||||||
self.maple_messages[0] = data
|
self.maple_messages[0] = data
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push_user_messages(self,user,data):
|
def push_user_messages(self,user,data):
|
||||||
self.user_users.append(user)
|
self.user_users.append(user)
|
||||||
self.user_messages.append(data)
|
self.user_messages.append(data)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def similar(self,a,b):
|
def similar(self,a,b):
|
||||||
return SequenceMatcher(None,a,b).ratio()
|
return SequenceMatcher(None,a,b).ratio()
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
terminate=False
|
terminate=False
|
||||||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
|
||||||
logger=logging.getLogger(__name__)
|
logger=logging.getLogger(__name__)
|
||||||
#######################################################################################
|
|
||||||
CONFIG_FILE={
|
CONFIG_FILE={
|
||||||
'small':'https://convaisharables.blob.core.windows.net/lsp/117M/config.json',
|
'small':'https://convaisharables.blob.core.windows.net/lsp/117M/config.json',
|
||||||
'medium':'https://convaisharables.blob.core.windows.net/lsp/345M/config.json'
|
'medium':'https://convaisharables.blob.core.windows.net/lsp/345M/config.json'
|
||||||
}
|
}
|
||||||
#######################################################################################
|
|
||||||
VOCAB_FILE={
|
VOCAB_FILE={
|
||||||
'small':'https://convaisharables.blob.core.windows.net/lsp/117M/vocab.json',
|
'small':'https://convaisharables.blob.core.windows.net/lsp/117M/vocab.json',
|
||||||
'medium':'https://convaisharables.blob.core.windows.net/lsp/345M/vocab.json'
|
'medium':'https://convaisharables.blob.core.windows.net/lsp/345M/vocab.json'
|
||||||
}
|
}
|
||||||
#######################################################################################
|
|
||||||
MERGE_FILE={
|
MERGE_FILE={
|
||||||
'small':'https://convaisharables.blob.core.windows.net/lsp/117M/merges.txt',
|
'small':'https://convaisharables.blob.core.windows.net/lsp/117M/merges.txt',
|
||||||
'medium':'https://convaisharables.blob.core.windows.net/lsp/345M/merges.txt'
|
'medium':'https://convaisharables.blob.core.windows.net/lsp/345M/merges.txt'
|
||||||
}
|
}
|
||||||
#######################################################################################
|
|
||||||
LSP_MODEL_URL={
|
LSP_MODEL_URL={
|
||||||
'multiref':{
|
'multiref':{
|
||||||
'medium_fs':'https://convaisharables.blob.core.windows.net/lsp/multiref/medium_fs.pkl',
|
'medium_fs':'https://convaisharables.blob.core.windows.net/lsp/multiref/medium_fs.pkl',
|
||||||
@ -77,18 +108,15 @@ class Plugin:
|
|||||||
'small_ft':'https://convaisharables.blob.core.windows.net/lsp/DSTC/medium_ft.pkl'
|
'small_ft':'https://convaisharables.blob.core.windows.net/lsp/DSTC/medium_ft.pkl'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#######################################################################################
|
|
||||||
REVERSE_MODEL_URL='https://convaisharables.blob.core.windows.net/lsp/multiref/small_reverse.pkl'
|
REVERSE_MODEL_URL='https://convaisharables.blob.core.windows.net/lsp/multiref/small_reverse.pkl'
|
||||||
OPINION="""
|
OPINION="""
|
||||||
"""
|
"""
|
||||||
#######################################################################################
|
|
||||||
WISDOM="""
|
WISDOM="""
|
||||||
"""
|
"""
|
||||||
#######################################################################################
|
|
||||||
PERSONALITY="""
|
PERSONALITY="""
|
||||||
[model]
|
[model]
|
||||||
data_folder=models
|
data_folder=models
|
||||||
model_size=medium
|
model_size=small
|
||||||
dataset=multiref
|
dataset=multiref
|
||||||
from_scratch=True
|
from_scratch=True
|
||||||
no_cuda=False
|
no_cuda=False
|
||||||
@ -102,15 +130,16 @@ class Plugin:
|
|||||||
num_samples=1
|
num_samples=1
|
||||||
max_turns_history=-1
|
max_turns_history=-1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
self.bot.history=MESSAGE_HISTORY()
|
self.bot.history=MESSAGE_HISTORY()
|
||||||
message_history=self.bot.history
|
message_history=self.bot.history
|
||||||
#############################################
|
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
self.bot.history.maple_messages.append("")
|
self.bot.history.maple_messages.append("")
|
||||||
#############################################
|
|
||||||
self.mode=0
|
self.mode=0
|
||||||
self.span=0
|
self.span=0
|
||||||
self.epoch_time_last=0
|
self.epoch_time_last=0
|
||||||
@ -131,7 +160,10 @@ class Plugin:
|
|||||||
else:
|
else:
|
||||||
self.mmi_model=None
|
self.mmi_model=None
|
||||||
self.mmi_tokenizer=None
|
self.mmi_tokenizer=None
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def http_get(self,url,temp_file):
|
def http_get(self,url,temp_file):
|
||||||
req=requests.get(url,stream=True)
|
req=requests.get(url,stream=True)
|
||||||
content_length=req.headers.get('Content-Length')
|
content_length=req.headers.get('Content-Length')
|
||||||
@ -142,7 +174,10 @@ class Plugin:
|
|||||||
progress.update(len(chunk))
|
progress.update(len(chunk))
|
||||||
temp_file.write(chunk)
|
temp_file.write(chunk)
|
||||||
progress.close()
|
progress.close()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def download_file(self,url,folder):
|
def download_file(self,url,folder):
|
||||||
if not os.path.exists(folder):
|
if not os.path.exists(folder):
|
||||||
os.makedirs(folder,exist_ok=True)
|
os.makedirs(folder,exist_ok=True)
|
||||||
@ -153,7 +188,10 @@ class Plugin:
|
|||||||
return
|
return
|
||||||
with open(os.path.join(folder,file_name),'wb') as f:
|
with open(os.path.join(folder,file_name),'wb') as f:
|
||||||
self.http_get(url,f)
|
self.http_get(url,f)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def download_model_folder(self,config):
|
def download_model_folder(self,config):
|
||||||
data_folder=config.get('model','data_folder')
|
data_folder=config.get('model','data_folder')
|
||||||
model_size=config.get('model','model_size')
|
model_size=config.get('model','model_size')
|
||||||
@ -163,7 +201,7 @@ class Plugin:
|
|||||||
os.makedirs(data_folder, exist_ok=True)
|
os.makedirs(data_folder, exist_ok=True)
|
||||||
target_folder_name=model_size+"_"+dataset+("_fs" if from_scratch else "_ft")
|
target_folder_name=model_size+"_"+dataset+("_fs" if from_scratch else "_ft")
|
||||||
target_folder=os.path.join(data_folder,target_folder_name)
|
target_folder=os.path.join(data_folder,target_folder_name)
|
||||||
self.logger.info(f"Downloading model files to {target_folder_name}...")
|
print(f'<<< _______maple_plugin >>> [ downloading model files ] - path: {target_folder_name}')
|
||||||
self.download_file(self.CONFIG_FILE[model_size],target_folder)
|
self.download_file(self.CONFIG_FILE[model_size],target_folder)
|
||||||
self.download_file(self.VOCAB_FILE[model_size],target_folder)
|
self.download_file(self.VOCAB_FILE[model_size],target_folder)
|
||||||
self.download_file(self.MERGE_FILE[model_size],target_folder)
|
self.download_file(self.MERGE_FILE[model_size],target_folder)
|
||||||
@ -173,7 +211,10 @@ class Plugin:
|
|||||||
raise ValueError(f"'{model_train_type}' not exist for dataset '{dataset}', please choose from [{k}]")
|
raise ValueError(f"'{model_train_type}' not exist for dataset '{dataset}', please choose from [{k}]")
|
||||||
self.download_file(self.LSP_MODEL_URL[dataset][model_train_type],target_folder)
|
self.download_file(self.LSP_MODEL_URL[dataset][model_train_type],target_folder)
|
||||||
return target_folder_name
|
return target_folder_name
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def download_reverse_model_folder(self,config):
|
def download_reverse_model_folder(self,config):
|
||||||
data_folder=config.get('model','data_folder')
|
data_folder=config.get('model','data_folder')
|
||||||
model_size='medium'
|
model_size='medium'
|
||||||
@ -181,18 +222,21 @@ class Plugin:
|
|||||||
os.makedirs(data_folder,exist_ok=True)
|
os.makedirs(data_folder,exist_ok=True)
|
||||||
target_folder_name=model_size+'_reverse'
|
target_folder_name=model_size+'_reverse'
|
||||||
target_folder=os.path.join(data_folder,target_folder_name)
|
target_folder=os.path.join(data_folder,target_folder_name)
|
||||||
self.logger.info(f"Downloading model files to {target_folder_name}...")
|
print(f'<<< _______maple_plugin >>> [ downloading model files ] - path: {target_folder_name}')
|
||||||
self.download_file(self.CONFIG_FILE[model_size],target_folder)
|
self.download_file(self.CONFIG_FILE[model_size],target_folder)
|
||||||
self.download_file(self.VOCAB_FILE[model_size],target_folder)
|
self.download_file(self.VOCAB_FILE[model_size],target_folder)
|
||||||
self.download_file(self.MERGE_FILE[model_size],target_folder)
|
self.download_file(self.MERGE_FILE[model_size],target_folder)
|
||||||
self.download_file(self.REVERSE_MODEL_URL,target_folder)
|
self.download_file(self.REVERSE_MODEL_URL,target_folder)
|
||||||
return target_folder_name
|
return target_folder_name
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def load_model(self,target_folder_name,config):
|
def load_model(self,target_folder_name,config):
|
||||||
data_folder=config.get('model','data_folder')
|
data_folder=config.get('model','data_folder')
|
||||||
model_size=config.get('model','model_size')
|
model_size=config.get('model','model_size')
|
||||||
no_cuda=config.getboolean('model', 'no_cuda')
|
no_cuda=config.getboolean('model', 'no_cuda')
|
||||||
self.logger.info(f"Loading model from {target_folder_name}...")
|
print(f'<<< _______maple_plugin >>> [ downloading model files ] - path: {target_folder_name}')
|
||||||
device=torch.device("cuda" if torch.cuda.is_available() and not no_cuda else "cpu")
|
device=torch.device("cuda" if torch.cuda.is_available() and not no_cuda else "cpu")
|
||||||
target_folder=os.path.join(data_folder,target_folder_name)
|
target_folder=os.path.join(data_folder,target_folder_name)
|
||||||
tokenizer=GPT2Tokenizer(os.path.join(target_folder, 'vocab.json'), os.path.join(target_folder,'merges.txt'))
|
tokenizer=GPT2Tokenizer(os.path.join(target_folder, 'vocab.json'), os.path.join(target_folder,'merges.txt'))
|
||||||
@ -209,12 +253,18 @@ class Plugin:
|
|||||||
model.to(device)
|
model.to(device)
|
||||||
model.eval()
|
model.eval()
|
||||||
return model,tokenizer
|
return model,tokenizer
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def set_seed(self,seed):
|
def set_seed(self,seed):
|
||||||
random.seed(seed)
|
random.seed(seed)
|
||||||
np.random.seed(seed)
|
np.random.seed(seed)
|
||||||
torch.manual_seed(seed)
|
torch.manual_seed(seed)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def top_k_top_p_filtering(self,logits,top_k=0,top_p=0.0,filter_value=-float('Inf')):
|
def top_k_top_p_filtering(self,logits,top_k=0,top_p=0.0,filter_value=-float('Inf')):
|
||||||
top_k=min(top_k,logits.size(-1))
|
top_k=min(top_k,logits.size(-1))
|
||||||
if top_k>0:
|
if top_k>0:
|
||||||
@ -229,7 +279,10 @@ class Plugin:
|
|||||||
indices_to_remove=sorted_indices_to_remove.scatter(dim=1,index=sorted_indices,src=sorted_indices_to_remove)
|
indices_to_remove=sorted_indices_to_remove.scatter(dim=1,index=sorted_indices,src=sorted_indices_to_remove)
|
||||||
logits[indices_to_remove]=filter_value
|
logits[indices_to_remove]=filter_value
|
||||||
return logits
|
return logits
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def sample_sequence(self,model,tokenizer,context_ids,config):
|
def sample_sequence(self,model,tokenizer,context_ids,config):
|
||||||
no_cuda=config.getboolean('model','no_cuda')
|
no_cuda=config.getboolean('model','no_cuda')
|
||||||
num_samples=config.getint('decoder','num_samples')
|
num_samples=config.getint('decoder','num_samples')
|
||||||
@ -257,7 +310,10 @@ class Plugin:
|
|||||||
if generated.shape[1]-len(context_ids)>=max_length:
|
if generated.shape[1]-len(context_ids)>=max_length:
|
||||||
break
|
break
|
||||||
return generated
|
return generated
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def select_using_mmi(self,mmi_model,mmi_tokenizer,candidates,config):
|
def select_using_mmi(self,mmi_model,mmi_tokenizer,candidates,config):
|
||||||
no_cuda=config.getboolean('model','no_cuda')
|
no_cuda=config.getboolean('model','no_cuda')
|
||||||
device=torch.device("cuda" if torch.cuda.is_available() and not no_cuda else "cpu")
|
device=torch.device("cuda" if torch.cuda.is_available() and not no_cuda else "cpu")
|
||||||
@ -274,7 +330,10 @@ class Plugin:
|
|||||||
scores=torch.stack(scores, dim=0)
|
scores=torch.stack(scores, dim=0)
|
||||||
winner=torch.multinomial(F.softmax(scores,dim=0),num_samples=1).item()
|
winner=torch.multinomial(F.softmax(scores,dim=0),num_samples=1).item()
|
||||||
return winner
|
return winner
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def generate_response(self,model,tokenizer,context,config,mmi_model=None,mmi_tokenizer=None):
|
def generate_response(self,model,tokenizer,context,config,mmi_model=None,mmi_tokenizer=None):
|
||||||
use_mmi=config.getboolean('model','use_mmi')
|
use_mmi=config.getboolean('model','use_mmi')
|
||||||
num_samples=config.getint('decoder','num_samples')
|
num_samples=config.getint('decoder','num_samples')
|
||||||
@ -297,10 +356,12 @@ class Plugin:
|
|||||||
best_i=self.select_using_mmi(mmi_model,mmi_tokenizer,candidates,config)
|
best_i=self.select_using_mmi(mmi_model,mmi_tokenizer,candidates,config)
|
||||||
return [texts[best_i]]
|
return [texts[best_i]]
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_search_for_maple(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_for_maple(self, mask=None, target=None, data=None, **kw):
|
||||||
##############################################
|
|
||||||
if mask.nick.lower()=='nickserv': return
|
if mask.nick.lower()=='nickserv': return
|
||||||
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick: return
|
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick: return
|
||||||
if mask.nick == self.bot.config["nick"]:
|
if mask.nick == self.bot.config["nick"]:
|
||||||
@ -310,27 +371,23 @@ class Plugin:
|
|||||||
mask.nick=data.split('[')[1].split(']')[0]
|
mask.nick=data.split('[')[1].split(']')[0]
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
##############################################
|
|
||||||
if self.epoch_time_boolean==True:
|
if self.epoch_time_boolean==True:
|
||||||
print('[ checking flood protection status ]')
|
print('[ checking flood protection status ]')
|
||||||
epoch_time_now=int(str(time()).split('.')[0])
|
epoch_time_now=int(str(time()).split('.')[0])
|
||||||
if epoch_time_now-self.epoch_time_last>=30:
|
if epoch_time_now-self.epoch_time_last>=30:
|
||||||
self.epoch_time_boolean=False
|
self.epoch_time_boolean=False
|
||||||
print('[ turned off flood protection ]')
|
print(f'<<< _______maple_plugin >>> [ turned off flood protection ]')
|
||||||
else:
|
else:
|
||||||
print('[ flood protection still on ]')
|
print(f'<<< _______maple_plugin >>> [ flood protection still on ]')
|
||||||
return
|
return
|
||||||
##############################################
|
|
||||||
data=data.strip().lower()
|
data=data.strip().lower()
|
||||||
self.bot.history.last_message=data
|
self.bot.history.last_message=data
|
||||||
##############################################
|
|
||||||
self.span=0
|
self.span=0
|
||||||
for _ in data.split():
|
for _ in data.split():
|
||||||
for __ in self.OPINION.split():
|
for __ in self.OPINION.split():
|
||||||
if _ == __:
|
if _ == __:
|
||||||
self.span=1
|
self.span=1
|
||||||
break
|
break
|
||||||
##############################################
|
|
||||||
if not data.lower().find('joke')==-1:
|
if not data.lower().find('joke')==-1:
|
||||||
self.bot.joke(mask,target,'')
|
self.bot.joke(mask,target,'')
|
||||||
if mask.nick == "d":
|
if mask.nick == "d":
|
||||||
@ -338,19 +395,18 @@ class Plugin:
|
|||||||
if data.find('hang with us')>-1:
|
if data.find('hang with us')>-1:
|
||||||
msg="ok, i'll hang out for a bit"
|
msg="ok, i'll hang out for a bit"
|
||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
print(f'<<< _______maple_plugin >>> [ maple is hanging out with us ]')
|
||||||
self.mode=1
|
self.mode=1
|
||||||
if data.find('leave us alone')>-1:
|
if data.find('leave us alone')>-1:
|
||||||
msg="ok, gotta go"
|
msg="ok, gotta go"
|
||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
|
print(f'<<< _______maple_plugin >>> [ maple is no longer hanging out with us ]')
|
||||||
self.mode=0
|
self.mode=0
|
||||||
##############################################
|
|
||||||
if self.mode==0:
|
if self.mode==0:
|
||||||
if not data.find(self.bot.config["nick"])>-1:
|
if not data.find(self.bot.config["nick"])>-1:
|
||||||
if self.span==0:
|
if self.span==0:
|
||||||
return
|
return
|
||||||
##############################################
|
|
||||||
self.span=0
|
self.span=0
|
||||||
##############################################
|
|
||||||
self.maple_io.append({'user':mask.nick,'message':f'{data}','target':target})
|
self.maple_io.append({'user':mask.nick,'message':f'{data}','target':target})
|
||||||
self.main()
|
self.main()
|
||||||
if len(self.maple_io) > 5:
|
if len(self.maple_io) > 5:
|
||||||
@ -359,29 +415,29 @@ class Plugin:
|
|||||||
self.epoch_time_last=self.epoch_time_now
|
self.epoch_time_last=self.epoch_time_now
|
||||||
self.epoch_time_boolean=True
|
self.epoch_time_boolean=True
|
||||||
msg=f"kind of busy at the moment {mask.nick}, i'll be right back"
|
msg=f"kind of busy at the moment {mask.nick}, i'll be right back"
|
||||||
print('[ turned on flood protection ]')
|
print(f'<<< _______maple_plugin >>> [ turned on flood protection ]')
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
async def indirect_maple(self, net=None, data=None, **kw):
|
async def indirect_maple(self, net=None, data=None, **kw):
|
||||||
##############################################
|
|
||||||
net_user=net[0]
|
net_user=net[0]
|
||||||
net_src=net[1]
|
net_src=net[1]
|
||||||
net_dest=net[2]
|
net_dest=net[2]
|
||||||
##############################################
|
|
||||||
if self.epoch_time_boolean==True:
|
if self.epoch_time_boolean==True:
|
||||||
print('[ checking flood protection status ]')
|
print(f'<<< _______maple_plugin >>> [ checking flood protection status ]')
|
||||||
epoch_time_now=int(str(time()).split('.')[0])
|
epoch_time_now=int(str(time()).split('.')[0])
|
||||||
if epoch_time_now-self.epoch_time_last>=30:
|
if epoch_time_now-self.epoch_time_last>=30:
|
||||||
self.epoch_time_boolean=False
|
self.epoch_time_boolean=False
|
||||||
print('[ turned off flood protection ]')
|
print(f'<<< _______maple_plugin >>> [ turned off flood protection ]')
|
||||||
else:
|
else:
|
||||||
print('[ flood protection still on ]')
|
print(f'<<< _______maple_plugin >>> [ flood protection still on ]')
|
||||||
return
|
return
|
||||||
##############################################
|
|
||||||
data=data.strip().lower()
|
data=data.strip().lower()
|
||||||
self.bot.history.last_message=data
|
self.bot.history.last_message=data
|
||||||
##############################################
|
|
||||||
self.maple_io.append({'user':net_user,'message':f'{data}','target':net_src})
|
self.maple_io.append({'user':net_user,'message':f'{data}','target':net_src})
|
||||||
self.main()
|
self.main()
|
||||||
if len(self.maple_io) > 5:
|
if len(self.maple_io) > 5:
|
||||||
@ -390,13 +446,16 @@ class Plugin:
|
|||||||
self.epoch_time_last=self.epoch_time_now
|
self.epoch_time_last=self.epoch_time_now
|
||||||
self.epoch_time_boolean=True
|
self.epoch_time_boolean=True
|
||||||
msg=f"kind of busy at the moment {net_user}, i'll be right back"
|
msg=f"kind of busy at the moment {net_user}, i'll be right back"
|
||||||
print('[ turned on flood protection ]')
|
print(f'<<< _______maple_plugin >>> [ turned on flood protection ]')
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
netschanlist=dims.list_channels_bridged(netsrc=net_src)
|
netschanlist=dims.list_channels_bridged(netsrc=net_src)
|
||||||
bridgedbus=(BUS(netschanlist))
|
bridgedbus=(BUS(netschanlist))
|
||||||
await bridgedbus.input(net_src,net_user,msg,True)
|
await bridgedbus.input(net_src,net_user,msg,True)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def run_chat(self,model,tokenizer,config,mmi_model=None,mmi_tokenizer=None):
|
def run_chat(self,model,tokenizer,config,mmi_model=None,mmi_tokenizer=None):
|
||||||
num_samples=config.getint('decoder','num_samples')
|
num_samples=config.getint('decoder','num_samples')
|
||||||
max_turns_history=config.getint('decoder','max_turns_history')
|
max_turns_history=config.getint('decoder','max_turns_history')
|
||||||
@ -405,7 +464,7 @@ class Plugin:
|
|||||||
config.set('decoder','seed',f'{datetime.now().microsecond}')
|
config.set('decoder','seed',f'{datetime.now().microsecond}')
|
||||||
try:
|
try:
|
||||||
if not type(self.bot.history.bounce)==bool:
|
if not type(self.bot.history.bounce)==bool:
|
||||||
print('<received bounce message>')
|
print(f'<<< _______maple_plugin >>> [ received bounce message ]')
|
||||||
USER=self.bot.history.bounce['user']
|
USER=self.bot.history.bounce['user']
|
||||||
MESSAGE=self.bot.history.bounce['message']
|
MESSAGE=self.bot.history.bounce['message']
|
||||||
TARGET=self.bot.history.bounce['target']
|
TARGET=self.bot.history.bounce['target']
|
||||||
@ -422,7 +481,7 @@ class Plugin:
|
|||||||
TARGET=maple_io['target']
|
TARGET=maple_io['target']
|
||||||
except:
|
except:
|
||||||
return True
|
return True
|
||||||
print(f'human > {MESSAGE}')
|
print(f'<<< _______maple_plugin >>> [ human > {MESSAGE} ] - {USER}{TARGET}')
|
||||||
|
|
||||||
self.bot.history.maple_message=MESSAGE
|
self.bot.history.maple_message=MESSAGE
|
||||||
if max_turns_history==0:
|
if max_turns_history==0:
|
||||||
@ -463,41 +522,48 @@ class Plugin:
|
|||||||
else:
|
else:
|
||||||
maple_message=random.choice(maple_messages)
|
maple_message=random.choice(maple_messages)
|
||||||
turn['maple_messages'].append(maple_message)
|
turn['maple_messages'].append(maple_message)
|
||||||
################################################################################### REPROCESSOR SOF
|
|
||||||
|
################################################################### REPROCESSOR SOF
|
||||||
# SIMILARITY
|
# SIMILARITY
|
||||||
|
|
||||||
for i in range(len(self.bot.history.maple_messages)):
|
for i in range(len(self.bot.history.maple_messages)):
|
||||||
if self.bot.history.similar(maple_message,str(self.bot.history.maple_messages[i]))>0.9:
|
if self.bot.history.similar(maple_message,str(self.bot.history.maple_messages[i]))>0.9:
|
||||||
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
||||||
print(f'maple - logic ! rejected // maple similarity - repeat of previous response')
|
print(f'<<< _______maple_plugin >>> [ maple - logic ! rejected ] - maple similarity - repeat of previous response')
|
||||||
self.bot.history.loopcount+=1
|
self.bot.history.loopcount+=1
|
||||||
return False
|
return False
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# MOCK / DUPE
|
# MOCK / DUPE
|
||||||
|
|
||||||
if self.bot.history.similar(maple_message,MESSAGE)>0.9:
|
if self.bot.history.similar(maple_message,MESSAGE)>0.9:
|
||||||
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
||||||
print(f'maple - logic ! rejected // human mock - maple response same as human')
|
print(f'<<< _______maple_plugin >>> [ maple - logic ! rejected ] - human mock - maple response same as human')
|
||||||
self.bot.history.loopcount+=1
|
self.bot.history.loopcount+=1
|
||||||
return False
|
return False
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# GPT LOOP GLITCH
|
# GPT LOOP GLITCH
|
||||||
|
|
||||||
n=len(maple_message.split())
|
n=len(maple_message.split())
|
||||||
i=len(set(maple_message.split()))
|
i=len(set(maple_message.split()))
|
||||||
if i<int(n/2):
|
if i<int(n/2):
|
||||||
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
||||||
print(f'maple - logic ! rejected // gpt loop glitch - reiterating same thing in multiples')
|
print(f'<<< _______maple_plugin >>> [ maple - logic ! rejected ] - gpt loop glitch - reiterating same thing in multiples')
|
||||||
self.bot.history.loopcount+=1
|
self.bot.history.loopcount+=1
|
||||||
return False
|
return False
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# LIMITED RESPONSE
|
# LIMITED RESPONSE
|
||||||
|
|
||||||
n=len(maple_message.split())
|
n=len(maple_message.split())
|
||||||
if i<3:
|
if i<3:
|
||||||
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
self.maple_io.append({'user':USER,'message':f'{MESSAGE}','target':TARGET})
|
||||||
print(f'maple - logic ! rejected // limited response - skip an unfinished token chain')
|
print(f'<<< _______maple_plugin >>> [ maple - logic ! rejected ] - limited response - skip an unfinished token chain')
|
||||||
self.bot.history.loopcount+=1
|
self.bot.history.loopcount+=1
|
||||||
return False
|
return False
|
||||||
###################################################################################
|
|
||||||
self.bot.history.push_maple_messages(maple_message)
|
self.bot.history.push_maple_messages(maple_message)
|
||||||
print(f'maple > {maple_message}')
|
print(f'<<< _______maple_plugin >>> [ maple > {maple_message} ]')
|
||||||
MAPLE_MESSAGE=maple_message.replace('lt 3','<3')
|
MAPLE_MESSAGE=maple_message.replace('lt 3','<3')
|
||||||
msg=f'{MAPLE_MESSAGE}'
|
msg=f'{MAPLE_MESSAGE}'
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
@ -508,11 +574,12 @@ class Plugin:
|
|||||||
async def truss(self,TARGET,USER,msg):
|
async def truss(self,TARGET,USER,msg):
|
||||||
await bridgedbus.input(TARGET,USER,msg,True)
|
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( 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
|
self.bot.history.loopcount=0
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
FLAG_OK=False
|
FLAG_OK=False
|
||||||
while not FLAG_OK:
|
while not FLAG_OK:
|
||||||
@ -521,5 +588,6 @@ class Plugin:
|
|||||||
self.bot.history.loopcount=0
|
self.bot.history.loopcount=0
|
||||||
self.maple_io=[]
|
self.maple_io=[]
|
||||||
FLAG_OK=True
|
FLAG_OK=True
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,42 +1,93 @@
|
|||||||
#-*- coding: utf-8 -*- ################################################################ SOF
|
#-*- coding: utf-8 -*- ################################################################ SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???DISCORD???
|
???DISCORD???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
###########################################################################################
|
import sys
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
import irc3
|
import irc3
|
||||||
###########################################################################################
|
|
||||||
if SERVICES_DISCORD:
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
from discord import Client
|
from discord import Client
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
###########################################################################################
|
from plugins.tool_log_plugin import FOG
|
||||||
if SERVICES_DISCORD:
|
|
||||||
DISCORD__SCHAN=int(os.environ['DISCORD__SCHAN'])
|
#######################################################################################
|
||||||
DISCORD__TOKEN=str(os.environ['DISCORD__TOKEN'])
|
#######################################################################################
|
||||||
###########################################################################################
|
|
||||||
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
DISCORD__SCHAN=int(getenv('DISCORD__SCHAN'))
|
||||||
|
DISCORD__TOKEN=getenv('DISCORD__TOKEN')
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
global client
|
global client
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
async def _d_bnc_msg(netsrc,usernick,netdest,data):
|
async def _d_bnc_msg(netsrc,usernick,netdest,data):
|
||||||
netsrc="^{}".format(netsrc)
|
netsrc="^{}".format(netsrc)
|
||||||
bridgedbus=(BUS(netdest))
|
bridgedbus=(BUS(netdest))
|
||||||
await bridgedbus.input(netsrc,usernick,data,True)
|
await bridgedbus.input(netsrc,usernick,data,True)
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def d_bnc_msg(netsrc,usernick,netdest,data,):
|
def d_bnc_msg(netsrc,usernick,netdest,data,):
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
asyncio.run_coroutine_threadsafe(_d_bnc_msg(netsrc,usernick,netdest,data),ircbot.loop)
|
asyncio.run_coroutine_threadsafe(_d_bnc_msg(netsrc,usernick,netdest,data),ircbot.loop)
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def start_discordbot(self):
|
def start_discordbot(self):
|
||||||
print(f'<<< _net_discord_plugin >>> [ discordbot started ]')
|
print(f'<<< _net_discord_plugin >>> [ discordbot started ]')
|
||||||
self.discordbot=DISCORDBOT()
|
self.discordbot=DISCORDBOT()
|
||||||
@ -44,9 +95,16 @@ if SERVICES_DISCORD:
|
|||||||
asyncio.set_event_loop(self.loop)
|
asyncio.set_event_loop(self.loop)
|
||||||
asyncio.run_coroutine_threadsafe(self.discordbot.client.start(DISCORD__TOKEN),self.loop)
|
asyncio.run_coroutine_threadsafe(self.discordbot.client.start(DISCORD__TOKEN),self.loop)
|
||||||
return self
|
return self
|
||||||
class DISCORDBOT:
|
|
||||||
if SERVICES_DISCORD:
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
class DISCORDBOT:
|
||||||
|
|
||||||
|
####################
|
||||||
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
intents=discord.Intents.default()
|
intents=discord.Intents.default()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
intents.messages = True
|
intents.messages = True
|
||||||
@ -58,11 +116,17 @@ if SERVICES_DISCORD:
|
|||||||
self.dbname="discordchat"
|
self.dbname="discordchat"
|
||||||
self.db=self.ircbot.db.getlist(self.dbname)
|
self.db=self.ircbot.db.getlist(self.dbname)
|
||||||
if not self.db: self.db=[]
|
if not self.db: self.db=[]
|
||||||
#######################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f'<<< _net_discord_plugin >>> [ discordbot connection made as {globals()["DISCORDBOT"].client.user.name} ]')
|
print(f'<<< _net_discord_plugin >>> [ discordbot connection made as {globals()["DISCORDBOT"].client.user.name} ]')
|
||||||
#######################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
async def listchannels(self):
|
async def listchannels(self):
|
||||||
print(f"<<< _net_discord_plugin >>> [ event: scanning channels ] - started")
|
print(f"<<< _net_discord_plugin >>> [ event: scanning channels ] - started")
|
||||||
discordchannels=list(globals()['DISCORDBOT'].client.get_all_channels())
|
discordchannels=list(globals()['DISCORDBOT'].client.get_all_channels())
|
||||||
@ -74,7 +138,10 @@ if SERVICES_DISCORD:
|
|||||||
dims.__create__('discord',channel_name)
|
dims.__create__('discord',channel_name)
|
||||||
print(f"<<< _net_discord_plugin >>> [ event: new channel ] - dims.__create__(discord,{channel_name}) - active channel record created")
|
print(f"<<< _net_discord_plugin >>> [ event: new channel ] - dims.__create__(discord,{channel_name}) - active channel record created")
|
||||||
globals()['DISCORDBOT'].push(channel.id,channel.name)
|
globals()['DISCORDBOT'].push(channel.id,channel.name)
|
||||||
#######################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
async def clear():
|
async def clear():
|
||||||
discordbot=guds.memory('discordbot')
|
discordbot=guds.memory('discordbot')
|
||||||
client=discordbot.client
|
client=discordbot.client
|
||||||
@ -92,7 +159,10 @@ if SERVICES_DISCORD:
|
|||||||
msg=f'<<< _net_discord_plugin >>> [ purging bridge ] - completed'
|
msg=f'<<< _net_discord_plugin >>> [ purging bridge ] - completed'
|
||||||
print(msg)
|
print(msg)
|
||||||
TRAP_FLAG=False
|
TRAP_FLAG=False
|
||||||
#######################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def push(id,name):
|
def push(id,name):
|
||||||
class discordchat:
|
class discordchat:
|
||||||
def __init__(self,id,name):
|
def __init__(self,id,name):
|
||||||
@ -109,10 +179,12 @@ if SERVICES_DISCORD:
|
|||||||
self.db.append([dc.id,f"^{dc.name}"])
|
self.db.append([dc.id,f"^{dc.name}"])
|
||||||
self.ircbot.db.setlist(self.dbname,self.db)
|
self.ircbot.db.setlist(self.dbname,self.db)
|
||||||
print(f'<<< _net_discord_plugin >>> [ new database entry ] > [{dc.id},^{dc.name}]')
|
print(f'<<< _net_discord_plugin >>> [ new database entry ] > [{dc.id},^{dc.name}]')
|
||||||
########################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
###################################################################################
|
|
||||||
discordbot=guds.memory('discordbot')
|
discordbot=guds.memory('discordbot')
|
||||||
client=discordbot.client
|
client=discordbot.client
|
||||||
if message.author.name == client.user.name:
|
if message.author.name == client.user.name:
|
||||||
@ -132,20 +204,31 @@ if SERVICES_DISCORD:
|
|||||||
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,USER,message.content,True),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}'
|
msg=f'<<< _net_discord_plugin >>> [ (d)({message.channel.id})({channel_name}) ] > {str(message.author)}: {message.content}'
|
||||||
print(msg)
|
print(msg)
|
||||||
###################################################################################
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
async def _d_discord_msg(self,target,msg):
|
async def _d_discord_msg(self,target,msg):
|
||||||
discordbot=guds.memory('discordbot')
|
discordbot=guds.memory('discordbot')
|
||||||
client=discordbot.client
|
client=discordbot.client
|
||||||
if [x.id for x in list(client.get_all_channels()) if x.name==target[1:]][0]:
|
if [x.id for x in list(client.get_all_channels()) if x.name==target[1:]][0]:
|
||||||
channel=client.get_channel([x.id for x in list(client.get_all_channels()) if x.name==target[1:]][0])
|
channel=client.get_channel([x.id for x in list(client.get_all_channels()) if x.name==target[1:]][0])
|
||||||
await channel.send(msg)
|
await channel.send(msg)
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def d_discord_cmd(target,cmd,):
|
def d_discord_cmd(target,cmd,):
|
||||||
discordbot=guds.memory('discordbot')
|
discordbot=guds.memory('discordbot')
|
||||||
if cmd=="purgebridges":
|
if cmd=="purgebridges":
|
||||||
asyncio.run_coroutine_threadsafe(discordbot.clear(),discordbot.client.loop)
|
asyncio.run_coroutine_threadsafe(discordbot.clear(),discordbot.client.loop)
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def d_discord_msg(target,msg,):
|
def d_discord_msg(target,msg,):
|
||||||
discordbot=guds.memory('discordbot')
|
discordbot=guds.memory('discordbot')
|
||||||
asyncio.run_coroutine_threadsafe(discordbot._d_discord_msg(target,msg),discordbot.client.loop)
|
asyncio.run_coroutine_threadsafe(discordbot._d_discord_msg(target,msg),discordbot.client.loop)
|
||||||
####################################################################################### EOF#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
from irc3.plugins import core
|
from irc3.plugins import core
|
||||||
@ -8,7 +10,10 @@ from random import randint as rint
|
|||||||
from random import shuffle
|
from random import shuffle
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class dr1p:
|
class dr1p:
|
||||||
def __init__():
|
def __init__():
|
||||||
dr1p.designation=""
|
dr1p.designation=""
|
||||||
@ -17,10 +22,12 @@ class dr1p:
|
|||||||
dr1p.color=""
|
dr1p.color=""
|
||||||
dr1p.keyid=""
|
dr1p.keyid=""
|
||||||
dr1p.home=""
|
dr1p.home=""
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
#######################################################################################
|
|
||||||
def generate_keyid_token(self,mode=1):
|
def generate_keyid_token(self,mode=1):
|
||||||
if mode:
|
if mode:
|
||||||
token=""
|
token=""
|
||||||
@ -38,7 +45,10 @@ class Plugin:
|
|||||||
shuffle(keyid)
|
shuffle(keyid)
|
||||||
keyid=''.join(keyid)
|
keyid=''.join(keyid)
|
||||||
return keyid
|
return keyid
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
dr1p.color=""
|
dr1p.color=""
|
||||||
@ -55,7 +65,10 @@ class Plugin:
|
|||||||
dr1p.color="\x0304"
|
dr1p.color="\x0304"
|
||||||
dr1p.keyid=self.generate_keyid_token(0)
|
dr1p.keyid=self.generate_keyid_token(0)
|
||||||
dr1p.token=self.generate_keyid_token(1)
|
dr1p.token=self.generate_keyid_token(1)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def server_ready(self):
|
def server_ready(self):
|
||||||
if not dr1p.designation=='core':
|
if not dr1p.designation=='core':
|
||||||
dr1p.token=self.generate_keyid_token()
|
dr1p.token=self.generate_keyid_token()
|
||||||
@ -64,45 +77,57 @@ class Plugin:
|
|||||||
dr1p.keyid=self.generate_keyid_token(0)
|
dr1p.keyid=self.generate_keyid_token(0)
|
||||||
dr1p.token=self.generate_keyid_token(1)
|
dr1p.token=self.generate_keyid_token(1)
|
||||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - purpose: {dr1p.purpose} - core - connected")
|
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - purpose: {dr1p.purpose} - core - connected")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.ERR_NICK)
|
@irc3.event(irc3.rfc.ERR_NICK)
|
||||||
def on_errnick(self,srv=None,retcode=None,me=None,nick=None,data=None):
|
def on_errnick(self,srv=None,retcode=None,me=None,nick=None,data=None):
|
||||||
###################################################################################
|
|
||||||
if not dr1p.designation=='core': return
|
if not dr1p.designation=='core': return
|
||||||
msg=f'err_nick - srv:{srv} - retcode:{retcode} - me:{me} - nick:{nick} - data:{data}'
|
msg=f'err_nick - srv:{srv} - retcode:{retcode} - me:{me} - nick:{nick} - data:{data}'
|
||||||
self.bot.privmsg("maple",msg.lower())
|
self.bot.privmsg("maple",msg.lower())
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.NEW_NICK)
|
@irc3.event(irc3.rfc.NEW_NICK)
|
||||||
def on_newnick(self,nick=None,new_nick=None):
|
def on_newnick(self,nick=None,new_nick=None):
|
||||||
###################################################################################
|
|
||||||
if not dr1p.designation=='core': return
|
if not dr1p.designation=='core': return
|
||||||
if nick==self.bot.config['nick'] or new_nick==self.bot.config['nick']:
|
if nick==self.bot.config['nick'] or new_nick==self.bot.config['nick']:
|
||||||
msg=f'new_nick - nick:{nick} - new_nick:{new_nick}'
|
msg=f'new_nick - nick:{nick} - new_nick:{new_nick}'
|
||||||
self.bot.privmsg("maple",msg.lower())
|
self.bot.privmsg("maple",msg.lower())
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.CTCP)
|
@irc3.event(irc3.rfc.CTCP)
|
||||||
def on_ctcp(self,mask=None,event=None,target=None,ctcp=None):
|
def on_ctcp(self,mask=None,event=None,target=None,ctcp=None):
|
||||||
###################################################################################
|
|
||||||
if not dr1p.designation=='core': return
|
if not dr1p.designation=='core': return
|
||||||
msg=f'ctcpd - mask:{mask} - event:{event} - target:{target} - ctcp:{ctcp}'
|
msg=f'ctcpd - mask:{mask} - event:{event} - target:{target} - ctcp:{ctcp}'
|
||||||
self.bot.privmsg("maple",msg.lower())
|
self.bot.privmsg("maple",msg.lower())
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.INVITE)
|
@irc3.event(irc3.rfc.INVITE)
|
||||||
def on_invite(self,mask=None,channel=None):
|
def on_invite(self,mask=None,channel=None):
|
||||||
###################################################################################
|
|
||||||
if not dr1p.designation=='core': return
|
if not dr1p.designation=='core': return
|
||||||
msg=f'invited - mask:{mask} - channel:{channel}'
|
msg=f'invited - mask:{mask} - channel:{channel}'
|
||||||
self.bot.privmsg("maple",msg.lower())
|
self.bot.privmsg("maple",msg.lower())
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.KICK)
|
@irc3.event(irc3.rfc.KICK)
|
||||||
def on_kick(self,mask=None,event=None,channel=None,target=None,data=None):
|
def on_kick(self,mask=None,event=None,channel=None,target=None,data=None):
|
||||||
###################################################################################
|
|
||||||
msg=f'kicked - mask:{mask} - event:{event} - target:{target} - data:{data}'
|
msg=f'kicked - mask:{mask} - event:{event} - target:{target} - data:{data}'
|
||||||
self.bot.privmsg(dr1p.home,msg)
|
self.bot.privmsg(dr1p.home,msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
def on_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
||||||
###################################################################################
|
|
||||||
if mask.nick=='d' and 'maple' in data and 'list' in data and 'hydra' in data:
|
if mask.nick=='d' and 'maple' in data and 'list' in data and 'hydra' in data:
|
||||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - purpose: {dr1p.purpose}"
|
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - purpose: {dr1p.purpose}"
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
@ -112,7 +137,6 @@ class Plugin:
|
|||||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - hostname: {socket.gethostname()} - plugin: {_}"
|
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - hostname: {socket.gethostname()} - plugin: {_}"
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
return
|
return
|
||||||
###################################################################################
|
|
||||||
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick:
|
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick:
|
||||||
data=""
|
data=""
|
||||||
return
|
return
|
||||||
@ -152,18 +176,21 @@ class Plugin:
|
|||||||
if keyid1==keyid2: self.bot.privmsg(dr1p.home,msg.lower())
|
if keyid1==keyid2: self.bot.privmsg(dr1p.home,msg.lower())
|
||||||
except:
|
except:
|
||||||
self.bot.privmsg(dr1p.home,"exception - "+msg.lower())
|
self.bot.privmsg(dr1p.home,"exception - "+msg.lower())
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.MY_PRIVMSG)
|
@irc3.event(irc3.rfc.MY_PRIVMSG)
|
||||||
def on_my_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
def on_my_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
||||||
###################################################################################
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
||||||
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
||||||
target=kw['channel']
|
target=kw['channel']
|
||||||
###################################################################################
|
|
||||||
if mask.nick==self.bot.config['nick']:
|
if mask.nick==self.bot.config['nick']:
|
||||||
###############################################################################
|
|
||||||
if kw['event']=='JOIN':
|
if kw['event']=='JOIN':
|
||||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - joined {target}".lower())
|
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - joined {target}".lower())
|
||||||
if target!=dr1p.home:
|
if target!=dr1p.home:
|
||||||
@ -183,5 +210,6 @@ class Plugin:
|
|||||||
else:
|
else:
|
||||||
msg=f"[hydra:{dr1p.keyid}] -"
|
msg=f"[hydra:{dr1p.keyid}] -"
|
||||||
self.bot.privmsg("maple",msg+f"quit {target} - {data}")
|
self.bot.privmsg("maple",msg+f"quit {target} - {data}")
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
@ -1,16 +1,40 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
???MATRIX???
|
???MATRIX???
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3,os,asyncio,re
|
import irc3,os,asyncio,re
|
||||||
from irc3.testing import ini2config
|
from irc3.testing import ini2config
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
from nio import AsyncClient, MatrixRoom, RoomMessageText
|
from nio import AsyncClient, MatrixRoom, RoomMessageText
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
||||||
################################################################ NET IRC - BOT CONFIG [2/4]
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def config_ircbot():
|
def config_ircbot():
|
||||||
config=ini2config("""
|
config=ini2config("""
|
||||||
[bot]
|
[bot]
|
||||||
@ -25,7 +49,59 @@ def config_ircbot():
|
|||||||
ssl_verify = CERT_NONE
|
ssl_verify = CERT_NONE
|
||||||
|
|
||||||
includes =
|
includes =
|
||||||
|
irc3.plugins.command
|
||||||
|
irc3.plugins.asynchronious
|
||||||
|
irc3.plugins.uptime
|
||||||
|
irc3.plugins.ctcp
|
||||||
|
irc3.plugins.cron
|
||||||
|
irc3.plugins.log
|
||||||
|
irc3.plugins.logger
|
||||||
|
irc3.plugins.userlist
|
||||||
|
plugins.tool_dims_plugin
|
||||||
|
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.storage_plugin
|
||||||
|
plugins.base_plugin
|
||||||
|
plugins.emote_plugin
|
||||||
|
plugins.fifo_plugin
|
||||||
|
plugins.url_grabber_plugin
|
||||||
|
plugins.youtube_plugin
|
||||||
|
plugins.net_discord_plugin
|
||||||
|
plugins.net_telegram_plugin
|
||||||
|
plugins.cmd_irc_plugin
|
||||||
|
plugins.crypto_plugin
|
||||||
|
plugins.notes_plugin
|
||||||
|
plugins.quote_plugin
|
||||||
|
plugins.ratesex_plugin
|
||||||
|
plugins.remind_plugin
|
||||||
|
plugins.timezonediff_plugin
|
||||||
|
plugins.sed_plugin
|
||||||
|
plugins.seen_plugin
|
||||||
|
plugins.strain_plugin
|
||||||
|
plugins.tell_plugin
|
||||||
|
plugins.twitter_plugin
|
||||||
|
plugins.ud_plugin
|
||||||
|
plugins.figlet_plugin
|
||||||
|
plugins.soundcloud_plugin
|
||||||
|
plugins.isup_plugin
|
||||||
|
plugins.tcpac_plugin
|
||||||
|
plugins.google_plugin
|
||||||
|
plugins.highlight_plugin
|
||||||
|
plugins.boombox_plugin
|
||||||
|
plugins.whoami_plugin
|
||||||
|
plugins.joke_plugin
|
||||||
|
plugins.maple_plugin
|
||||||
|
plugins.tool_colors_plugin
|
||||||
|
plugins.dsa_plugin
|
||||||
|
plugins.openai_plugin
|
||||||
|
plugins.ip_plugin
|
||||||
|
plugins.datetime_plugin
|
||||||
|
plugins.ping_plugin
|
||||||
|
#plugins.ansi_plugin
|
||||||
|
|
||||||
autojoins =
|
autojoins =
|
||||||
'#b0tsh0p'
|
'#b0tsh0p'
|
||||||
@ -35,7 +111,7 @@ def config_ircbot():
|
|||||||
flood_burst = 0
|
flood_burst = 0
|
||||||
flood_rate = 1
|
flood_rate = 1
|
||||||
flood_rate_delay = 1
|
flood_rate_delay = 1
|
||||||
storage = json://databases/maple_db.json
|
storage = sqlite://databases/maple_db.sqlite
|
||||||
|
|
||||||
[irc3.plugins.command]
|
[irc3.plugins.command]
|
||||||
cmd = ?
|
cmd = ?
|
||||||
@ -77,39 +153,62 @@ def config_ircbot():
|
|||||||
for i,_ in enumerate(config['autojoins']):
|
for i,_ in enumerate(config['autojoins']):
|
||||||
config['autojoins'][i]=_.replace("'","")
|
config['autojoins'][i]=_.replace("'","")
|
||||||
return ircbot
|
return ircbot
|
||||||
############################################################### NET IRC - BOT STARTUP [3/4]
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def start_ircbot(self):
|
def start_ircbot(self):
|
||||||
print(f'<<< _____net_irc_plugin >>> [ ircbot started ]')
|
print(f'<<< _____net_irc_plugin >>> [ ircbot started ]')
|
||||||
self.ircbot.loop=self.loop
|
self.ircbot.loop=self.loop
|
||||||
self.ircbot.run(forever=True)
|
self.ircbot.run(forever=True)
|
||||||
return self
|
return self
|
||||||
###################################################################### NET IRC - MAIN [4/4]
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
async def _d_irc_msg(target,msg,) -> None:
|
async def _d_irc_msg(target,msg,) -> None:
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
await ircbot.privmsg(target,msg,)
|
await ircbot.privmsg(target,msg,)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def d_irc_msg(target,msg,):
|
def d_irc_msg(target,msg,):
|
||||||
self=guds.memory('ircbot')
|
self=guds.memory('ircbot')
|
||||||
asyncio.run_coroutine_threadsafe(_d_irc_msg(target,msg),self.loop)
|
asyncio.run_coroutine_threadsafe(_d_irc_msg(target,msg),self.loop)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
###########################################################################################
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
print(f'<<< _____net_irc_plugin >>> [ plugin loaded ]')
|
print(f'<<< _____net_irc_plugin >>> [ plugin loaded ]')
|
||||||
globals()['guds'].memories.append([self.bot,'net_irc_plugin:start_ircbot.self'])
|
globals()['guds'].memories.append([self.bot,'net_irc_plugin:start_ircbot.self'])
|
||||||
self.dbname="ircchat"
|
self.dbname="ircchat"
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def connection_made(self):
|
def connection_made(self):
|
||||||
print(f'<<< _____net_irc_plugin >>> [ event: ircbot connection made ]')
|
print(f'<<< _____net_irc_plugin >>> [ event: ircbot connection made ]')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def server_ready(self):
|
def server_ready(self):
|
||||||
print(f'<<< _____net_irc_plugin >>> [ event: ircbot server ready ]')
|
print(f'<<< _____net_irc_plugin >>> [ event: ircbot server ready ]')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def connection_lost(self):
|
def connection_lost(self):
|
||||||
print(f'<<< _____net_irc_plugin >>> [ event: ircbot connection lost ]')
|
print(f'<<< _____net_irc_plugin >>> [ event: ircbot connection lost ]')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
async def on_privmsg(self, mask=None, target=None, data=None, **kw):
|
async def on_privmsg(self, mask=None, target=None, data=None, **kw):
|
||||||
msg=f"<<< _____net_irc_plugin >>> [ (i)({self.bot.config['host']})({target}) ] > {mask.nick}: {regex.sub('',data)}"
|
msg=f"<<< _____net_irc_plugin >>> [ (i)({self.bot.config['host']})({target}) ] > {mask.nick}: {regex.sub('',data)}"
|
||||||
@ -121,10 +220,14 @@ class Plugin:
|
|||||||
await bridgedbus.input(target,mask.nick,data,True)
|
await bridgedbus.input(target,mask.nick,data,True)
|
||||||
else: # bot
|
else: # bot
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push(self,channel):
|
def push(self,channel):
|
||||||
self.db=self.bot.db.getlist(self.dbname)
|
self.db=self.bot.db.getlist(self.dbname)
|
||||||
if not self.db: self.db=[]
|
if not self.db:
|
||||||
|
self.db=[]
|
||||||
class ircchat:
|
class ircchat:
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.channel=channel
|
self.channel=channel
|
||||||
@ -138,19 +241,19 @@ class Plugin:
|
|||||||
self.db.append([ircc.channel])
|
self.db.append([ircc.channel])
|
||||||
self.bot.db.setlist(self.dbname,self.db)
|
self.bot.db.setlist(self.dbname,self.db)
|
||||||
print(f'<<< _____net_irc_plugin >>> [ new database entry ] > [{ircc.channel}]')
|
print(f'<<< _____net_irc_plugin >>> [ new database entry ] > [{ircc.channel}]')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
||||||
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
||||||
target=kw['channel']
|
target=kw['channel']
|
||||||
###################################################################################
|
|
||||||
if not mask.nick==self.bot.config['nick']: # this section is the user
|
if not mask.nick==self.bot.config['nick']: # this section is the user
|
||||||
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
||||||
print(msg)
|
print(msg)
|
||||||
###################################################################################
|
else:
|
||||||
else: # this section is the bot
|
|
||||||
###############################################################################
|
|
||||||
if kw['event']=='JOIN':
|
if kw['event']=='JOIN':
|
||||||
result=dims.isircchannel(channel=target,return_index=True)
|
result,i=dims.isircchannel(channel=target,return_index=True)
|
||||||
guds.mask=mask
|
guds.mask=mask
|
||||||
if not result:
|
if not result:
|
||||||
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
||||||
@ -158,37 +261,40 @@ class Plugin:
|
|||||||
dims.__create__('irc',target)
|
dims.__create__('irc',target)
|
||||||
print(f"<<< ___tool_dims_plugin >>> [ event: join ] - dims.__create__(irc,{target}) - active channel record created")
|
print(f"<<< ___tool_dims_plugin >>> [ event: join ] - dims.__create__(irc,{target}) - active channel record created")
|
||||||
self.push(target)
|
self.push(target)
|
||||||
###############################################################################
|
|
||||||
elif kw['event']=='PART':
|
elif kw['event']=='PART':
|
||||||
###########################################################################
|
result,i=dims.isircchannel(channel=target,return_index=True)
|
||||||
result=dims.isircchannel(channel=target,return_index=True)
|
|
||||||
###########################################################################
|
|
||||||
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
||||||
print(msg)
|
print(msg)
|
||||||
dims.__delete__('irc',i)
|
dims.__delete__('irc',i)
|
||||||
print(f"<<< ___tool_dims_plugin >>> [ event: part ] - dims.__delete__(irc,{target}) - active channel record deleted")
|
print(f"<<< ___tool_dims_plugin >>> [ event: part ] - dims.__delete__(irc,{target}) - active channel record deleted")
|
||||||
###############################################################################
|
|
||||||
elif kw['event']=='QUIT':
|
elif kw['event']=='QUIT':
|
||||||
###########################################################################
|
result,i=dims.isircchannel(target)
|
||||||
result=dims.isircchannel(target)
|
|
||||||
###########################################################################
|
|
||||||
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
msg=f'<<< _____net_irc_plugin >>> [ event: join_part_quit ] - nick: {mask.nick} - target: {target} - event: {kw["event"]} - data: {data}'
|
||||||
print(msg)
|
print(msg)
|
||||||
dims.__delete__('irc',i)
|
dims.__delete__('irc',i)
|
||||||
print(f"<<< ___tool_dims_plugin >>> [ event: quit ] - dims.__delete__(irc,{target}) - active channel record deleted")
|
print(f"<<< ___tool_dims_plugin >>> [ event: quit ] - dims.__delete__(irc,{target}) - active channel record deleted")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.TOPIC)
|
@irc3.event(irc3.rfc.TOPIC)
|
||||||
def on_topic(self,mask=None,target=None,data=None,**kw):
|
def on_topic(self,mask=None,target=None,data=None,**kw):
|
||||||
if not mask.nick==self.bot.config['nick']:
|
if not mask.nick==self.bot.config['nick']:
|
||||||
msg=f"{mask.nick}: target: {target} - event: topic - data: {data}"
|
msg=f"{mask.nick}: target: {target} - event: topic - data: {data}"
|
||||||
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.INVITE)
|
@irc3.event(irc3.rfc.INVITE)
|
||||||
def on_invite(self,mask=None,target=None,data=None,**kw):
|
def on_invite(self,mask=None,target=None,data=None,**kw):
|
||||||
if not mask.nick==self.bot.config['nick']:
|
if not mask.nick==self.bot.config['nick']:
|
||||||
msg=f"{mask.nick}: target: {target} - event: invite - data: {data}"
|
msg=f"{mask.nick}: target: {target} - event: invite - data: {data}"
|
||||||
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.KICK)
|
@irc3.event(irc3.rfc.KICK)
|
||||||
def on_kick(self,mask=None,target=None,data=None,**kw):
|
def on_kick(self,mask=None,target=None,data=None,**kw):
|
||||||
try:
|
try:
|
||||||
@ -197,7 +303,10 @@ class Plugin:
|
|||||||
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.MODE)
|
@irc3.event(irc3.rfc.MODE)
|
||||||
def on_mode(self,mask=None,target=None,data=None,**kw):
|
def on_mode(self,mask=None,target=None,data=None,**kw):
|
||||||
try:
|
try:
|
||||||
@ -206,7 +315,10 @@ class Plugin:
|
|||||||
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.NEW_NICK)
|
@irc3.event(irc3.rfc.NEW_NICK)
|
||||||
def on_new_kick(self,mask=None,target=None,data=None,**kw):
|
def on_new_kick(self,mask=None,target=None,data=None,**kw):
|
||||||
try:
|
try:
|
||||||
@ -215,7 +327,10 @@ class Plugin:
|
|||||||
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.CTCP)
|
@irc3.event(irc3.rfc.CTCP)
|
||||||
def on_ctcp(self,mask=None,target=None,data=None,**kw):
|
def on_ctcp(self,mask=None,target=None,data=None,**kw):
|
||||||
try:
|
try:
|
||||||
@ -224,4 +339,6 @@ class Plugin:
|
|||||||
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
print("<<< _____net_irc_plugin >>> [ "+msg+" ]")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
@ -1,10 +1,16 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
???MATRIX???
|
???MATRIX???
|
||||||
###############################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
import irc3,asyncio,os,re,aiofiles.os
|
###################
|
||||||
#import magic
|
|
||||||
# from PIL import Image
|
import irc3, asyncio, os, re, sys, aiofiles.os
|
||||||
from nio import AsyncClient, MatrixRoom, RoomMessageText, UploadResponse
|
from nio import AsyncClient, MatrixRoom, RoomMessageText, UploadResponse
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
@ -12,33 +18,57 @@ if SERVICES_MATRIX:
|
|||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
###########################################################################################
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
try:
|
try:
|
||||||
MATRIX_HOMESERVER=os.environ['MATRIX_HOMESERVER']
|
s = os.environ[s]
|
||||||
MATRIX___USERNAME=os.environ['MATRIX___USERNAME']
|
return s
|
||||||
MATRIX___PASSWORD=os.environ['MATRIX___PASSWORD']
|
|
||||||
###########################################################################################
|
|
||||||
except:
|
except:
|
||||||
pass
|
fog=FOG().fog
|
||||||
###########################################################################################
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
MATRIX_HOMESERVER=getenv('MATRIX_HOMESERVER')
|
||||||
|
MATRIX___USERNAME=getenv('MATRIX___USERNAME')
|
||||||
|
MATRIX___PASSWORD=getenv('MATRIX___PASSWORD')
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
matrix_bot_credentials=[]
|
matrix_bot_credentials=[]
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def add_credentials(credential):
|
def add_credentials(credential):
|
||||||
matrix_bot_credentials.append(credential)
|
matrix_bot_credentials.append(credential)
|
||||||
print(f'<<< __net_matrix_plugin >>> [ add_credentials ] - added {credential} credentials to net_matrix_plugin.matrix_bot_credentials')
|
print(f'<<< __net_matrix_plugin >>> [ add_credentials ] - added {credential} credentials to net_matrix_plugin.matrix_bot_credentials')
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def check_credentials(self,against_credential):
|
def check_credentials(self,against_credential):
|
||||||
flag_match=False
|
flag_match=False
|
||||||
for credential in matrix_bot_credentials:
|
for credential in matrix_bot_credentials:
|
||||||
if not credential.find(against_credential):
|
if not credential.find(against_credential):
|
||||||
flag_match=True
|
flag_match=True
|
||||||
print(f'<<< __net_matrix_plugin >>> [ check_credentials ] - found {credential} against {against_credential}')
|
print(f'<<< __net_matrix_plugin >>> [ check_credentials ] - found {credential} against {against_credential}')
|
||||||
#######################################################################################
|
|
||||||
if not flag_match:
|
if not flag_match:
|
||||||
print(f'<<< __net_matrix_plugin >>> [ check_credentials ] - no credentials found matching {against_credential}')
|
print(f'<<< __net_matrix_plugin >>> [ check_credentials ] - no credentials found matching {against_credential}')
|
||||||
#######################################################################################
|
|
||||||
return flag_match
|
return flag_match
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def start_matrixbot(self):
|
def start_matrixbot(self):
|
||||||
print(f'<<< __net_matrix_plugin >>> [ matrixbot started ]')
|
print(f'<<< __net_matrix_plugin >>> [ matrixbot started ]')
|
||||||
add_credentials("@maple.or.g1mp:matrix.org")
|
add_credentials("@maple.or.g1mp:matrix.org")
|
||||||
@ -49,7 +79,10 @@ if SERVICES_MATRIX:
|
|||||||
asyncio.run_coroutine_threadsafe(self.matrixbot.main(),self.loop)
|
asyncio.run_coroutine_threadsafe(self.matrixbot.main(),self.loop)
|
||||||
self.matrixbot.client=AsyncClient(MATRIX_HOMESERVER, MATRIX___USERNAME)
|
self.matrixbot.client=AsyncClient(MATRIX_HOMESERVER, MATRIX___USERNAME)
|
||||||
return self
|
return self
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
async def _d_matrix_msg(target,msg,) -> None:
|
async def _d_matrix_msg(target,msg,) -> None:
|
||||||
matrixbot=guds.memory('matrixbot')
|
matrixbot=guds.memory('matrixbot')
|
||||||
await matrixbot.client.room_send(
|
await matrixbot.client.room_send(
|
||||||
@ -57,11 +90,16 @@ if SERVICES_MATRIX:
|
|||||||
message_type="m.room.message",
|
message_type="m.room.message",
|
||||||
content={"msgtype":"m.text","body":msg},
|
content={"msgtype":"m.text","body":msg},
|
||||||
)
|
)
|
||||||
###########################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def d_matrix_msg(target,msg,):
|
def d_matrix_msg(target,msg,):
|
||||||
matrixbot=guds.memory('matrixbot')
|
matrixbot=guds.memory('matrixbot')
|
||||||
asyncio.run_coroutine_threadsafe(_d_matrix_msg(target,msg),matrixbot.loop)
|
asyncio.run_coroutine_threadsafe(_d_matrix_msg(target,msg),matrixbot.loop)
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
class MATRIXBOT:
|
class MATRIXBOT:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ircbot=guds.memory('ircbot')
|
self.ircbot=guds.memory('ircbot')
|
||||||
@ -71,7 +109,8 @@ if SERVICES_MATRIX:
|
|||||||
print(f'<<< __net_matrix_plugin >>> [ plugin loaded ]')
|
print(f'<<< __net_matrix_plugin >>> [ plugin loaded ]')
|
||||||
globals()['guds'].memories.append([self,'net_matrix_plugin:start_matrixbot.self'])
|
globals()['guds'].memories.append([self,'net_matrix_plugin:start_matrixbot.self'])
|
||||||
|
|
||||||
#######################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
async def message_callback(self,room: MatrixRoom, event: RoomMessageText) -> None:
|
async def message_callback(self,room: MatrixRoom, event: RoomMessageText) -> None:
|
||||||
if guds.timestamp_check('matrix_boot')==False:
|
if guds.timestamp_check('matrix_boot')==False:
|
||||||
return
|
return
|
||||||
@ -83,7 +122,6 @@ if SERVICES_MATRIX:
|
|||||||
bridgedbus=(BUS(netschanlist))
|
bridgedbus=(BUS(netschanlist))
|
||||||
await bridgedbus.input(room.room_id,user_src,event.body,True)
|
await bridgedbus.input(room.room_id,user_src,event.body,True)
|
||||||
if not event.body.lower().find("maple")==-1:
|
if not event.body.lower().find("maple")==-1:
|
||||||
#######################################################################################
|
|
||||||
self.blackhole=[]
|
self.blackhole=[]
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
dbname="blackhole"
|
dbname="blackhole"
|
||||||
@ -101,7 +139,10 @@ if SERVICES_MATRIX:
|
|||||||
d_cmd_irc(room.room_id,event.sender,'!OftXgmqAFOPEatmvLU:pcriot.org','listrooms','')
|
d_cmd_irc(room.room_id,event.sender,'!OftXgmqAFOPEatmvLU:pcriot.org','listrooms','')
|
||||||
elif not event.body.find('purgebridges')==-1:
|
elif not event.body.find('purgebridges')==-1:
|
||||||
d_cmd_irc(room.room_id,event.sender,'!OftXgmqAFOPEatmvLU:pcriot.org','purgebridges','')
|
d_cmd_irc(room.room_id,event.sender,'!OftXgmqAFOPEatmvLU:pcriot.org','purgebridges','')
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def push(self,room_id):
|
def push(self,room_id):
|
||||||
class matrixchat:
|
class matrixchat:
|
||||||
def __init__(self,room_id):
|
def __init__(self,room_id):
|
||||||
@ -116,7 +157,10 @@ if SERVICES_MATRIX:
|
|||||||
self.db.append([mc.room_id])
|
self.db.append([mc.room_id])
|
||||||
self.ircbot.db.setlist(self.dbname,self.db)
|
self.ircbot.db.setlist(self.dbname,self.db)
|
||||||
print(f'<<< __net_matrix_plugin >>> [ new database entry ] > [{mc.room_id}]')
|
print(f'<<< __net_matrix_plugin >>> [ new database entry ] > [{mc.room_id}]')
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
async def main(self,) -> None:
|
async def main(self,) -> None:
|
||||||
self.client.add_event_callback(self.message_callback,RoomMessageText)
|
self.client.add_event_callback(self.message_callback,RoomMessageText)
|
||||||
await self.client.login(MATRIX___PASSWORD)
|
await self.client.login(MATRIX___PASSWORD)
|
||||||
@ -130,7 +174,8 @@ if SERVICES_MATRIX:
|
|||||||
dims.__create__('matrix',_room)
|
dims.__create__('matrix',_room)
|
||||||
print(f"<<< ___tool_dims_plugin >>> [ event: join ] - dims.__create__(matrix,{_room}) - active room record created")
|
print(f"<<< ___tool_dims_plugin >>> [ event: join ] - dims.__create__(matrix,{_room}) - active room record created")
|
||||||
self.push(_room)
|
self.push(_room)
|
||||||
###################################################################################
|
|
||||||
print(f'<<< __net_matrix_plugin >>> [ await client.sync_forever(timeout=5000) ]')
|
print(f'<<< __net_matrix_plugin >>> [ await client.sync_forever(timeout=5000) ]')
|
||||||
await self.client.sync_forever(timeout=5000) # milliseconds
|
await self.client.sync_forever(timeout=5000) # milliseconds
|
||||||
####################################################################################### EOF#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
@ -1,42 +1,73 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
???TELEGRAM???
|
???TELEGRAM???
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import configparser
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
import telegram
|
import telegram
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from telegram import ChatAction, ParseMode
|
from telegram import ChatAction, ParseMode
|
||||||
from telegram.ext import (ChatJoinRequestHandler, CommandHandler, Filters,
|
from telegram.ext import (ChatJoinRequestHandler, CommandHandler, Filters,
|
||||||
MessageHandler, Updater)
|
MessageHandler, Updater)
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
###########################################################################################
|
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
###########################################################################################
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
try:
|
try:
|
||||||
TELEGRAM_TOKEN=os.environ['TELEGRAM_TOKEN']
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
except:
|
except:
|
||||||
pass
|
fog=FOG().fog
|
||||||
###########################################################################################
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
TELEGRAM_TOKEN=getenv('TELEGRAM_TOKEN')
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def start_telegrambot(self):
|
def start_telegrambot(self):
|
||||||
print(f'<<< net_telegram_plugin >>> [ telegrambot started ]')
|
print(f'<<< net_telegram_plugin >>> [ telegrambot started ]')
|
||||||
self.telegrambot=TELEGRAMBOT()
|
self.telegrambot=TELEGRAMBOT()
|
||||||
globals()['guds'].memories.append([self.telegrambot,'net_telegram_plugin:start_telegrambot.self'])
|
globals()['guds'].memories.append([self.telegrambot,'net_telegram_plugin:start_telegrambot.self'])
|
||||||
self.telegrambot.main()
|
self.telegrambot.main()
|
||||||
return self
|
return self
|
||||||
###########################################################################################
|
|
||||||
class TELEGRAMBOT:
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
class TELEGRAMBOT:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ircbot=guds.memory('ircbot')
|
self.ircbot=guds.memory('ircbot')
|
||||||
self.dbname="telegramchat"
|
self.dbname="telegramchat"
|
||||||
@ -45,21 +76,36 @@ if SERVICES_TELEGRAM:
|
|||||||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||||
level=logging.INFO)
|
level=logging.INFO)
|
||||||
logger=logging.getLogger(__name__)
|
logger=logging.getLogger(__name__)
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def start(self,update,context):
|
def start(self,update,context):
|
||||||
update.message.reply_text('Hi!')
|
update.message.reply_text('Hi!')
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def help(self,update,context):
|
def help(self,update,context):
|
||||||
update.message.reply_text('Help!')
|
update.message.reply_text('Help!')
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
async def _t_bnc_msg(self,netsrc,usernick,netdest,data,):
|
async def _t_bnc_msg(self,netsrc,usernick,netdest,data,):
|
||||||
bridgedbus=(BUS(netdest))
|
bridgedbus=(BUS(netdest))
|
||||||
await bridgedbus.input(f"${netsrc}",usernick,data,True)
|
await bridgedbus.input(f"${netsrc}",usernick,data,True)
|
||||||
###########################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def t_bnc_msg(self,netsrc,usernick,netdest,data,):
|
def t_bnc_msg(self,netsrc,usernick,netdest,data,):
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
asyncio.run_coroutine_threadsafe(self._t_bnc_msg(netsrc,usernick,netdest,data),ircbot.loop)
|
asyncio.run_coroutine_threadsafe(self._t_bnc_msg(netsrc,usernick,netdest,data),ircbot.loop)
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def push(self,chat_id):
|
def push(self,chat_id):
|
||||||
class telegramchat:
|
class telegramchat:
|
||||||
def __init__(self,id,type,title):
|
def __init__(self,id,type,title):
|
||||||
@ -77,7 +123,10 @@ if SERVICES_TELEGRAM:
|
|||||||
self.db.append([tgc.id,f"${tgc.title}",tgc.type])
|
self.db.append([tgc.id,f"${tgc.title}",tgc.type])
|
||||||
self.ircbot.db.setlist(self.dbname,self.db)
|
self.ircbot.db.setlist(self.dbname,self.db)
|
||||||
print(f'<<< net_telegram_plugin >>> [ new database entry ] > [{tgc.id},${tgc.title},{tgc.type}]')
|
print(f'<<< net_telegram_plugin >>> [ new database entry ] > [{tgc.id},${tgc.title},{tgc.type}]')
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def echo(self,update,context):
|
def echo(self,update,context):
|
||||||
from plugins.tool_bus_plugin import BUS
|
from plugins.tool_bus_plugin import BUS
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
@ -96,10 +145,16 @@ if SERVICES_TELEGRAM:
|
|||||||
netschanlist.append(TARGET)
|
netschanlist.append(TARGET)
|
||||||
bridgedbus=(BUS(netschanlist))
|
bridgedbus=(BUS(netschanlist))
|
||||||
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,USER,msg,True),self.ircbot.loop)
|
asyncio.run_coroutine_threadsafe(bridgedbus.input(TARGET,USER,msg,True),self.ircbot.loop)
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def error(self,update,context):
|
def error(self,update,context):
|
||||||
self.logger.warning('Update "%s" caused error "%s"',update,context.error)
|
self.logger.warning('Update "%s" caused error "%s"',update,context.error)
|
||||||
#######################################################################################
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
self.updater=Updater(TELEGRAM_TOKEN,use_context=True)
|
self.updater=Updater(TELEGRAM_TOKEN,use_context=True)
|
||||||
self.api=self.updater.bot
|
self.api=self.updater.bot
|
||||||
@ -109,7 +164,10 @@ if SERVICES_TELEGRAM:
|
|||||||
self.dp.add_handler(MessageHandler(Filters.text,self.echo))
|
self.dp.add_handler(MessageHandler(Filters.text,self.echo))
|
||||||
self.dp.add_error_handler(self.error)
|
self.dp.add_error_handler(self.error)
|
||||||
self.updater.start_polling()
|
self.updater.start_polling()
|
||||||
###########################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def d_telegram_msg(target,msg):
|
def d_telegram_msg(target,msg):
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
telegram_groups=ircbot.db.getlist('telegramchat')
|
telegram_groups=ircbot.db.getlist('telegramchat')
|
||||||
@ -118,4 +176,6 @@ if SERVICES_TELEGRAM:
|
|||||||
group=_group[0]
|
group=_group[0]
|
||||||
telegrambot=guds.memory('telegrambot')
|
telegrambot=guds.memory('telegrambot')
|
||||||
telegrambot.api.send_message(group,msg)
|
telegrambot.api.send_message(group,msg)
|
||||||
####################################################################################### EOF#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,28 +1,38 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import timeago
|
import timeago
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=True)
|
@command(permission='admin', public=True, show_in_help_list=True)
|
||||||
def notes(self, *args, **kwargs):
|
def notes(self, *args, **kwargs):
|
||||||
"""list/write/del notes
|
"""list/write/del notes
|
||||||
%%notes [<cmd>] [<operation>]
|
%%notes [<cmd>] [<operation>]
|
||||||
"""
|
"""
|
||||||
return self.note(*args)
|
return self.note(*args)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def note(self, mask, target, args):
|
def note(self, mask, target, args):
|
||||||
"""list/write/del notes
|
"""list/write/del notes
|
||||||
@ -42,8 +52,10 @@ class Plugin:
|
|||||||
elif cmd in ["r", "read"]:
|
elif cmd in ["r", "read"]:
|
||||||
self.note_read(mask, target, args)
|
self.note_read(mask, target, args)
|
||||||
return
|
return
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def note_del(self, mask, target, args):
|
def note_del(self, mask, target, args):
|
||||||
"""Delete Note or * for all notes
|
"""Delete Note or * for all notes
|
||||||
@ -73,8 +85,10 @@ class Plugin:
|
|||||||
msg = "{} Removed".format(note_uuid_hash)
|
msg = "{} Removed".format(note_uuid_hash)
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def note_list(self, mask, target, args):
|
def note_list(self, mask, target, args):
|
||||||
"""List All Note Names
|
"""List All Note Names
|
||||||
@ -94,8 +108,10 @@ class Plugin:
|
|||||||
note_msg = note.get("note_msg")
|
note_msg = note.get("note_msg")
|
||||||
msg = "<{}> {} | {} | {}".format(note_from, note_time, note_msg, note_uuid)
|
msg = "<{}> {} | {} | {}".format(note_from, note_time, note_msg, note_uuid)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def note_read(self, mask, target, args):
|
def note_read(self, mask, target, args):
|
||||||
"""Display Note
|
"""Display Note
|
||||||
@ -138,8 +154,10 @@ class Plugin:
|
|||||||
msg = "<{}> {} | {} | {}".format(note_from, note_time, note_msg, note_uuid)
|
msg = "<{}> {} | {} | {}".format(note_from, note_time, note_msg, note_uuid)
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=True, show_in_help_list=False)
|
@command(permission='admin', public=True, show_in_help_list=False)
|
||||||
def note_write(self, mask, target, args):
|
def note_write(self, mask, target, args):
|
||||||
"""Add Note
|
"""Add Note
|
||||||
@ -159,7 +177,6 @@ class Plugin:
|
|||||||
msg = "Note Added! {}".format(note_uuid)
|
msg = "Note Added! {}".format(note_uuid)
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import irc3
|
import irc3
|
||||||
@ -9,48 +12,90 @@ import requests
|
|||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from random import randint as rint
|
from random import randint as rint
|
||||||
from random import choices
|
from random import choices
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
OPENAI_KEY = os.environ['OPENAI_KEY']
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
OPENAI_KEY = getenv('OPENAI_KEY')
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
DREY="\x02\x0315"
|
DREY="\x02\x0315"
|
||||||
GREY="\x02\x0314"
|
GREY="\x02\x0314"
|
||||||
DRED="\x02\x0302"
|
DRED="\x02\x0302"
|
||||||
LRED="\x02\x0312"
|
LRED="\x02\x0312"
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class OPENAI_MESSAGE_HISTORY():
|
class OPENAI_MESSAGE_HISTORY():
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
openai_messages = []
|
openai_messages = []
|
||||||
user_messages = []
|
user_messages = []
|
||||||
user_users = []
|
user_users = []
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.processing=0
|
self.processing=0
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push_openai_messages(self,data):
|
def push_openai_messages(self,data):
|
||||||
self.openai_messages = self.openai_messages[-1:] + self.openai_messages[:-1]
|
self.openai_messages = self.openai_messages[-1:] + self.openai_messages[:-1]
|
||||||
self.openai_messages[0] = data
|
self.openai_messages[0] = data
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push_user_messages(self,user,data):
|
def push_user_messages(self,user,data):
|
||||||
self.user_users.append(user)
|
self.user_users.append(user)
|
||||||
self.user_messages.append(data)
|
self.user_messages.append(data)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def similar(self,a,b):
|
def similar(self,a,b):
|
||||||
return SequenceMatcher(None,a,b).ratio()
|
return SequenceMatcher(None,a,b).ratio()
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.bot.openai_history=OPENAI_MESSAGE_HISTORY()
|
self.bot.openai_history=OPENAI_MESSAGE_HISTORY()
|
||||||
#############################################
|
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
self.bot.openai_history.openai_messages.append("")
|
self.bot.openai_history.openai_messages.append("")
|
||||||
#############################################
|
|
||||||
self.openai_io=[]
|
self.openai_io=[]
|
||||||
self.start_chat_log=""
|
self.start_chat_log=""
|
||||||
self.lastterm=""
|
self.lastterm=""
|
||||||
@ -63,8 +108,10 @@ class Plugin:
|
|||||||
self.presence_penalty=0.0
|
self.presence_penalty=0.0
|
||||||
self.flipcolor=False
|
self.flipcolor=False
|
||||||
self.default_load()
|
self.default_load()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def ai(self, mask, target, args):
|
def ai(self, mask, target, args):
|
||||||
"""OpenAi Question A Term
|
"""OpenAi Question A Term
|
||||||
@ -72,10 +119,8 @@ class Plugin:
|
|||||||
"""
|
"""
|
||||||
term=' '.join(args['<term>'])
|
term=' '.join(args['<term>'])
|
||||||
if not term[-1] == ".": term+="."
|
if not term[-1] == ".": term+="."
|
||||||
openai.api_key = OPENAPI_KEY
|
openai.api_key = OPENAI_KEY
|
||||||
######################################################################################
|
|
||||||
print(f"<<< openai: processing {target} {mask.nick.lower()} message: {term.lower()}")
|
print(f"<<< openai: processing {target} {mask.nick.lower()} message: {term.lower()}")
|
||||||
######################################################################################
|
|
||||||
MESSAGE_OK=True
|
MESSAGE_OK=True
|
||||||
TRAP_OK=True
|
TRAP_OK=True
|
||||||
LOOP_COUNT_LIMIT=5
|
LOOP_COUNT_LIMIT=5
|
||||||
@ -95,66 +140,12 @@ class Plugin:
|
|||||||
presence_penalty=self.presence_penalty
|
presence_penalty=self.presence_penalty
|
||||||
)
|
)
|
||||||
self.lastresponse=response
|
self.lastresponse=response
|
||||||
##################################################################################
|
|
||||||
openai_message=response.choices[0].text
|
openai_message=response.choices[0].text
|
||||||
USER=mask.nick
|
USER=mask.nick
|
||||||
MESSAGE=term
|
MESSAGE=term
|
||||||
# ################################################################################### REPROCESSOR SOF
|
|
||||||
# # SIMILARITY - QUERY SENT VS QUERY ANSWER
|
|
||||||
# if MESSAGE_OK:
|
|
||||||
# if self.bot.openai_history.similar(openai_message.lower(),term.lower())>0.4:
|
|
||||||
# self.openai_io.append({'user':USER,'message':MESSAGE,'target':target})
|
|
||||||
# print(f'openai - logic ! rejected // openai similarity - response too similar to query')
|
|
||||||
# TRAP_OK=False
|
|
||||||
# ################################################################################### REPROCESSOR SOF
|
|
||||||
# # SIMILARITY - QUERY ANSWER VS PERSONALITY PROFILE DATABASE
|
|
||||||
# if MESSAGE_OK:
|
|
||||||
# if self.bot.openai_history.similar(openai_message.lower().strip(),' '.join(self.start_chat_log.strip().splitlines())[:len(openai_message.strip())])>0.4:
|
|
||||||
# self.openai_io.append({'user':USER,'message':MESSAGE,'target':target})
|
|
||||||
# print(f'openai - logic ! rejected // openai similarity - response too similar to persoanlity profile database')
|
|
||||||
# TRAP_OK=False
|
|
||||||
# ###################################################################################
|
|
||||||
# # SIMILARITY - HISTORY
|
|
||||||
# if MESSAGE_OK:
|
|
||||||
# for i in range(len(self.bot.openai_history.openai_messages)):
|
|
||||||
# if self.bot.openai_history.similar(openai_message,str(self.bot.openai_history.openai_messages[i]))>0.8:
|
|
||||||
# self.openai_io.append({'user':USER,'message':MESSAGE,'target':target})
|
|
||||||
# print(f'openai - logic ! rejected // openai similarity - repeat of previous response')
|
|
||||||
# TRAP_OK=False
|
|
||||||
# ###################################################################################
|
|
||||||
# # MOCK / DUPE
|
|
||||||
# if MESSAGE_OK:
|
|
||||||
# if self.bot.openai_history.similar(openai_message,MESSAGE)>0.8:
|
|
||||||
# self.openai_io.append({'user':USER,'message':MESSAGE,'target':target})
|
|
||||||
# print(f'openai - logic ! rejected // human mock - openai response same as human')
|
|
||||||
# TRAP_OK=False
|
|
||||||
# ###################################################################################
|
|
||||||
# # GPT LOOP GLITCH
|
|
||||||
# if MESSAGE_OK:
|
|
||||||
# n=len(openai_message.split())
|
|
||||||
# i=len(set(openai_message.split()))
|
|
||||||
# if i<int(n/2):
|
|
||||||
# self.openai_io.append({'user':USER,'message':MESSAGE,'target':target})
|
|
||||||
# print(f'openai - logic ! rejected // gpt loop glitch - reiterating same thing in multiples')
|
|
||||||
# TRAP_OK=False
|
|
||||||
# ###################################################################################
|
|
||||||
# # LIMITED RESPONSE
|
|
||||||
# if MESSAGE_OK:
|
|
||||||
# n=len(openai_message.split())
|
|
||||||
# if i<3:
|
|
||||||
# self.openai_io.append({'user':USER,'message':MESSAGE,'target':target})
|
|
||||||
# print(f'openai - logic ! rejected // limited response - skip an unfinished token chain')
|
|
||||||
# TRAP_OK=False
|
|
||||||
###################################################################################
|
|
||||||
if MESSAGE_OK and TRAP_OK:
|
if MESSAGE_OK and TRAP_OK:
|
||||||
self.bot.openai_history.push_openai_messages(openai_message)
|
self.bot.openai_history.push_openai_messages(openai_message)
|
||||||
_msg = re.findall(r'.{1,400}(?:\s+|$)', openai_message)
|
_msg = re.findall(r'.{1,400}(?:\s+|$)', openai_message)
|
||||||
#if len(_msg) > 1:
|
|
||||||
# if len(_msg[0]) < len(_msg[1])//2:
|
|
||||||
# print(f'openai - discovered and removed a preface glitch: {_msg[0].strip()}')
|
|
||||||
# _msg.reverse()
|
|
||||||
# _msg.pop()
|
|
||||||
# _msg.reverse()
|
|
||||||
COLOR=""
|
COLOR=""
|
||||||
self.flipcolor = not self.flipcolor
|
self.flipcolor = not self.flipcolor
|
||||||
if self.flipcolor:
|
if self.flipcolor:
|
||||||
@ -168,20 +159,22 @@ class Plugin:
|
|||||||
self.bot.privmsg(target, f"{COLOR}{_.strip()}\x0F")
|
self.bot.privmsg(target, f"{COLOR}{_.strip()}\x0F")
|
||||||
MESSAGE_OK=False
|
MESSAGE_OK=False
|
||||||
print('<<< openai finished >>>')
|
print('<<< openai finished >>>')
|
||||||
###################################################################################
|
|
||||||
if LOOP_COUNT > LOOP_COUNT_LIMIT:
|
if LOOP_COUNT > LOOP_COUNT_LIMIT:
|
||||||
print(f"<<< openai failed: bouncing to mapleai >>>")
|
print(f"<<< openai failed: bouncing to mapleai >>>")
|
||||||
self.bot.history.bounce={'user':USER,'message':term,'target':target}
|
self.bot.history.bounce={'user':USER,'message':term,'target':target}
|
||||||
#MESSAGE=f"{GREY}<<< {DRED}i got nothing to say {GREY}>>>"
|
|
||||||
#self.bot.privmsg(target, f"{USER}: {MESSAGE}")
|
|
||||||
break
|
break
|
||||||
################################################################################### REPROCESSOR EOF
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def random_float(self,n):
|
def random_float(self,n):
|
||||||
i=float(rint(0,n))
|
i=float(rint(0,n))
|
||||||
i/=10
|
i/=10
|
||||||
return i
|
return i
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def print_response_properties(self,target):
|
def print_response_properties(self,target):
|
||||||
self.bot.privmsg(target, f"{DRED} model{GREY}: {LRED}{self.default_model}")
|
self.bot.privmsg(target, f"{DRED} model{GREY}: {LRED}{self.default_model}")
|
||||||
self.bot.privmsg(target, f"{DRED} temperature{GREY}: {LRED}{self.temperature}")
|
self.bot.privmsg(target, f"{DRED} temperature{GREY}: {LRED}{self.temperature}")
|
||||||
@ -189,7 +182,10 @@ class Plugin:
|
|||||||
self.bot.privmsg(target, f"{DRED} top_p{GREY}: {LRED}{self.top_p}")
|
self.bot.privmsg(target, f"{DRED} top_p{GREY}: {LRED}{self.top_p}")
|
||||||
self.bot.privmsg(target, f"{DRED}frequency_penalty{GREY}: {LRED}{self.frequency_penalty}")
|
self.bot.privmsg(target, f"{DRED}frequency_penalty{GREY}: {LRED}{self.frequency_penalty}")
|
||||||
self.bot.privmsg(target, f"{DRED} presence_penalty{GREY}: {LRED}{self.presence_penalty}")
|
self.bot.privmsg(target, f"{DRED} presence_penalty{GREY}: {LRED}{self.presence_penalty}")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def airand(self, mask, target, args):
|
def airand(self, mask, target, args):
|
||||||
"""OpenAi Randomize Response Properties
|
"""OpenAi Randomize Response Properties
|
||||||
@ -208,7 +204,10 @@ class Plugin:
|
|||||||
self.presence_penalty=self.random_float(20)
|
self.presence_penalty=self.random_float(20)
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}randomizing personality properties {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}randomizing personality properties {GREY}>>>"))
|
||||||
self.print_response_properties(target)
|
self.print_response_properties(target)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def default_load(self):
|
def default_load(self):
|
||||||
FILE='%s/../personalities/default.db' % dir_path
|
FILE='%s/../personalities/default.db' % dir_path
|
||||||
f=open(FILE,'r')
|
f=open(FILE,'r')
|
||||||
@ -216,7 +215,10 @@ class Plugin:
|
|||||||
if self.start_chat_log.find('\n')==0:
|
if self.start_chat_log.find('\n')==0:
|
||||||
self.start_chat_log=self.start_chat_log[1:]
|
self.start_chat_log=self.start_chat_log[1:]
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def airead(self, mask, target, args):
|
def airead(self, mask, target, args):
|
||||||
"""OpenAi Read Current Personality
|
"""OpenAi Read Current Personality
|
||||||
@ -230,7 +232,10 @@ class Plugin:
|
|||||||
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
||||||
for __ in msg:
|
for __ in msg:
|
||||||
self.bot.privmsg(target, f'{__.strip()}')
|
self.bot.privmsg(target, f'{__.strip()}')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aishow(self, mask, target, args):
|
def aishow(self, mask, target, args):
|
||||||
"""OpenAi Show Current Personality Properties and Values.
|
"""OpenAi Show Current Personality Properties and Values.
|
||||||
@ -238,7 +243,10 @@ class Plugin:
|
|||||||
"""
|
"""
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}showing current personality properties {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}showing current personality properties {GREY}>>>"))
|
||||||
self.print_response_properties(target)
|
self.print_response_properties(target)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aiterm(self, mask, target, args):
|
def aiterm(self, mask, target, args):
|
||||||
"""OpenAi Show Last Term.
|
"""OpenAi Show Last Term.
|
||||||
@ -249,7 +257,10 @@ class Plugin:
|
|||||||
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
||||||
for __ in msg:
|
for __ in msg:
|
||||||
self.bot.privmsg(target, f'{__.strip()}')
|
self.bot.privmsg(target, f'{__.strip()}')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def airesponse(self, mask, target, args):
|
def airesponse(self, mask, target, args):
|
||||||
"""OpenAi Show Last Server Response.
|
"""OpenAi Show Last Server Response.
|
||||||
@ -267,11 +278,9 @@ class Plugin:
|
|||||||
PROMPT_TOKENS=MODEL=self.lastresponse['usage']['prompt_tokens']
|
PROMPT_TOKENS=MODEL=self.lastresponse['usage']['prompt_tokens']
|
||||||
TOTAL_TOKENS=MODEL=self.lastresponse['usage']['total_tokens']
|
TOTAL_TOKENS=MODEL=self.lastresponse['usage']['total_tokens']
|
||||||
_TEXT=re.findall(r'.{1,400}(?:\s+|$)', TEXT)
|
_TEXT=re.findall(r'.{1,400}(?:\s+|$)', TEXT)
|
||||||
#msg.append(f'{GREY}[{DRED}usage{GREY}]')
|
|
||||||
msg.append(f'{DRED}completion_tokens{GREY}: {LRED}{COMPLETION_TOKENS}')
|
msg.append(f'{DRED}completion_tokens{GREY}: {LRED}{COMPLETION_TOKENS}')
|
||||||
msg.append(f' {DRED}prompt_tokens{GREY}: {LRED}{PROMPT_TOKENS}')
|
msg.append(f' {DRED}prompt_tokens{GREY}: {LRED}{PROMPT_TOKENS}')
|
||||||
msg.append(f' {DRED}total_tokens{GREY}: {LRED}{TOTAL_TOKENS}')
|
msg.append(f' {DRED}total_tokens{GREY}: {LRED}{TOTAL_TOKENS}')
|
||||||
#msg.append(f'{GREY}[{DRED}choices{GREY}]')
|
|
||||||
msg.append(f' {DRED}index{GREY}: {LRED}{INDEX}')
|
msg.append(f' {DRED}index{GREY}: {LRED}{INDEX}')
|
||||||
msg.append(f' {DRED}logprobs{GREY}: {LRED}{LOGPROBS}')
|
msg.append(f' {DRED}logprobs{GREY}: {LRED}{LOGPROBS}')
|
||||||
if len(_TEXT) > 1:
|
if len(_TEXT) > 1:
|
||||||
@ -287,7 +296,10 @@ class Plugin:
|
|||||||
msg.append(f'{LRED}{_.strip()}')
|
msg.append(f'{LRED}{_.strip()}')
|
||||||
for _ in msg:
|
for _ in msg:
|
||||||
self.bot.privmsg(target, _)
|
self.bot.privmsg(target, _)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def ailist(self, mask, target, args):
|
def ailist(self, mask, target, args):
|
||||||
"""OpenAi List Personalities
|
"""OpenAi List Personalities
|
||||||
@ -299,7 +311,10 @@ class Plugin:
|
|||||||
for i,_ in enumerate(FILES):
|
for i,_ in enumerate(FILES):
|
||||||
FILE=_.split('/')[-1].replace('.db','')
|
FILE=_.split('/')[-1].replace('.db','')
|
||||||
self.bot.privmsg(target, f'{DRED}{i}{GREY}: {LRED}{FILE}')
|
self.bot.privmsg(target, f'{DRED}{i}{GREY}: {LRED}{FILE}')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aiload(self, mask, target, args):
|
def aiload(self, mask, target, args):
|
||||||
"""OpenAi Load Personalities
|
"""OpenAi Load Personalities
|
||||||
@ -325,7 +340,10 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}error{GREY}: {LRED}could not load this personality database, maybe invalid index number {GREY}>>>'))
|
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}error{GREY}: {LRED}could not load this personality database, maybe invalid index number {GREY}>>>'))
|
||||||
return
|
return
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aiwrite(self, mask, target, args):
|
def aiwrite(self, mask, target, args):
|
||||||
"""OpenAi List Personalities
|
"""OpenAi List Personalities
|
||||||
@ -344,7 +362,10 @@ class Plugin:
|
|||||||
f.write(f'{self.start_chat_log}\n')
|
f.write(f'{self.start_chat_log}\n')
|
||||||
f.close()
|
f.close()
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}created {msg} personality database {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}created {msg} personality database {GREY}>>>"))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aitrain(self, mask, target, args):
|
def aitrain(self, mask, target, args):
|
||||||
"""OpenAi Question A Term
|
"""OpenAi Question A Term
|
||||||
@ -359,7 +380,10 @@ class Plugin:
|
|||||||
f.close()
|
f.close()
|
||||||
self.start_chat_log=f'{self.start_chat_log}\n{term}'
|
self.start_chat_log=f'{self.start_chat_log}\n{term}'
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}trained {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}trained {GREY}>>>"))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aidefault(self, mask, target, args):
|
def aidefault(self, mask, target, args):
|
||||||
"""OpenAi Return to Defaults
|
"""OpenAi Return to Defaults
|
||||||
@ -373,7 +397,10 @@ class Plugin:
|
|||||||
self.presence_penalty=0.0
|
self.presence_penalty=0.0
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}setting personality and properties to defaults {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}setting personality and properties to defaults {GREY}>>>"))
|
||||||
self.print_response_properties(target)
|
self.print_response_properties(target)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aiset(self, mask, target, args):
|
def aiset(self, mask, target, args):
|
||||||
"""OpenAi Set Response Properties. Properties are default_model, temperature, max_tokens, top_p, frequency_penalty, presence_penalty. Example Usage: ?aiset top_p 1.0
|
"""OpenAi Set Response Properties. Properties are default_model, temperature, max_tokens, top_p, frequency_penalty, presence_penalty. Example Usage: ?aiset top_p 1.0
|
||||||
@ -384,7 +411,6 @@ class Plugin:
|
|||||||
MODELS=["text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
|
MODELS=["text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
|
||||||
prop=""
|
prop=""
|
||||||
val=""
|
val=""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
prop=msg.split()[0].lower()
|
prop=msg.split()[0].lower()
|
||||||
val=msg.split()[1].lower()
|
val=msg.split()[1].lower()
|
||||||
@ -457,7 +483,10 @@ class Plugin:
|
|||||||
return
|
return
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}{prop} property set to the value {val} {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}{prop} property set to the value {val} {GREY}>>>"))
|
||||||
self.print_response_properties(target)
|
self.print_response_properties(target)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin')
|
@command(permission='admin')
|
||||||
def aiclear(self, mask, target, args):
|
def aiclear(self, mask, target, args):
|
||||||
"""OpenAi Clear Term
|
"""OpenAi Clear Term
|
||||||
@ -469,7 +498,6 @@ class Plugin:
|
|||||||
f.close()
|
f.close()
|
||||||
self.start_chat_log = ""
|
self.start_chat_log = ""
|
||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}cleared {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}cleared {GREY}>>>"))
|
||||||
#######################################################################################
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import random
|
import random
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bot):
|
def __init__(self,bot):
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.JOIN)
|
@irc3.event(irc3.rfc.JOIN)
|
||||||
def quote_user_join(self, mask, channel, **kw):
|
def quote_user_join(self, mask, channel, **kw):
|
||||||
"""quote a user when they join"""
|
"""quote a user when they join"""
|
||||||
@ -31,8 +39,10 @@ class Plugin:
|
|||||||
msg=self.bot.emo(msg)
|
msg=self.bot.emo(msg)
|
||||||
print(f'\n{msg}\n')
|
print(f'\n{msg}\n')
|
||||||
self.bot.privmsg(channel,msg)
|
self.bot.privmsg(channel,msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def quote(self,mask,target, args):
|
def quote(self,mask,target, args):
|
||||||
"""quote user message
|
"""quote user message
|
||||||
@ -62,8 +72,10 @@ class Plugin:
|
|||||||
status=f"\x02\x0304error \x02\x0303>\x0F {e.message[0]['message']}'"
|
status=f"\x02\x0304error \x02\x0303>\x0F {e.message[0]['message']}'"
|
||||||
msg=self.bot.emo(status)
|
msg=self.bot.emo(status)
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view',show_in_help_list=False)
|
@command(permission='view',show_in_help_list=False)
|
||||||
def quotes(self, mask, target, args):
|
def quotes(self, mask, target, args):
|
||||||
"""quotes user
|
"""quotes user
|
||||||
@ -82,7 +94,6 @@ class Plugin:
|
|||||||
msg=user+' \x02\x0303>\x0F '+quote_user[i]
|
msg=user+' \x02\x0303>\x0F '+quote_user[i]
|
||||||
msg=self.bot.emo(msg)
|
msg=self.bot.emo(msg)
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
import irc3
|
import irc3
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
__doc__ = '''#######################################################################################
|
__doc__ = '''#######################################################################################
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
@ -48,6 +56,8 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdyymMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
|||||||
####################################################################################################
|
####################################################################################################
|
||||||
#################################################################################################'''
|
#################################################################################################'''
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
rgb2irc = { 52: '16', 94: '17', 100: '18', 58: '19', 22: '20', 29: '21', 23: '22', 24: '23', 17: '24', 54: '25', 53: '26', 89: '27',
|
rgb2irc = { 52: '16', 94: '17', 100: '18', 58: '19', 22: '20', 29: '21', 23: '22', 24: '23', 17: '24', 54: '25', 53: '26', 89: '27',
|
||||||
88: '28', 130: '29', 142: '30', 64: '31', 28: '32', 35: '33', 30: '34', 25: '35', 18: '36', 91: '37', 90: '38', 125: '39',
|
88: '28', 130: '29', 142: '30', 64: '31', 28: '32', 35: '33', 30: '34', 25: '35', 18: '36', 91: '37', 90: '38', 125: '39',
|
||||||
@ -107,17 +117,22 @@ set2rgb = { 52: '#470000', 94: '#472100', 100: '#474700', 58: '#324700'
|
|||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def ratesex_request(self,site,commands):
|
def ratesex_request(self,site,commands):
|
||||||
USER_AGENT_BROWSER="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
|
USER_AGENT_BROWSER="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
|
||||||
USER_AGENT_CURL="curl/7.29.0"
|
USER_AGENT_CURL="curl/7.29.0"
|
||||||
STATUS_BAD_CODE=":( - error code: {}"
|
STATUS_BAD_CODE=":( - error code: {}"
|
||||||
STATUS_BAD_REASON=":( - failed reason: {}"
|
STATUS_BAD_REASON=":( - failed reason: {}"
|
||||||
STATUS_OK=":)"
|
STATUS_OK=":)"
|
||||||
|
|
||||||
if site != 'rate':
|
if site != 'rate':
|
||||||
url = f"https://{site}.rate.sx/{commands}"
|
url = f"https://{site}.rate.sx/{commands}"
|
||||||
else:
|
else:
|
||||||
@ -133,34 +148,40 @@ class Plugin:
|
|||||||
return STATUS_OK + response
|
return STATUS_OK + response
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def escape_ansi(self,line):
|
def escape_ansi(self,line):
|
||||||
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
|
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
|
||||||
return ansi_escape.sub('', str(line))
|
return ansi_escape.sub('', str(line))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def invert_dict(self,d):
|
def invert_dict(self,d):
|
||||||
return {v: k for k, v in d.items()}
|
return {v: k for k, v in d.items()}
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def enumerate_dict(self,d):
|
def enumerate_dict(self,d):
|
||||||
return list(zip(list(d),list(invert_dict(d)),range(len(d))))
|
return list(zip(list(d),list(invert_dict(d)),range(len(d))))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def organize_dict(self,d):
|
def organize_dict(self,d):
|
||||||
_d=list(d.values())
|
_d=list(d.values())
|
||||||
return _d.sort()
|
return _d.sort()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def escape_ansi(self,line):
|
def escape_ansi(self,line):
|
||||||
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
|
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
|
||||||
return ansi_escape.sub('', str(line))
|
return ansi_escape.sub('', str(line))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def hex2gravity(self,h):
|
def hex2gravity(self,h):
|
||||||
r,g,b=int(h[1:3],16),int(h[3:5],16),int(h[5:7],16)
|
r,g,b=int(h[1:3],16),int(h[3:5],16),int(h[5:7],16)
|
||||||
@ -203,6 +224,7 @@ class Plugin:
|
|||||||
return str(f"\x03{rgb2irc[self.invert_dict(set2rgb)[nearest_color]]}")
|
return str(f"\x03{rgb2irc[self.invert_dict(set2rgb)[nearest_color]]}")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def parse_control(self,s):
|
def parse_control(self,s):
|
||||||
px=[]
|
px=[]
|
||||||
@ -214,12 +236,14 @@ class Plugin:
|
|||||||
return px,py
|
return px,py
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def findall(self,s,w):
|
def findall(self,s,w):
|
||||||
return [i for i in range(len(s)) if s.startswith(w, i)]
|
return [i for i in range(len(s)) if s.startswith(w, i)]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def color_line(self,s,t):
|
def color_line(self,s,t):
|
||||||
codes=["\x1b[0m","\x1b[30m","\x1b[31m","\x1b[32m","\x1b[33m","\x1b[34m","\x1b[35m","\x1b[36m","\x1b[37m","\x1b[40m","\x1b[41m","\x1b[42m","\x1b[43m","\x1b[44m","\x1b[45m","\x1b[46m","\x1b[47m","\x1b(B","\x1b[m","\x1b[2m"]
|
codes=["\x1b[0m","\x1b[30m","\x1b[31m","\x1b[32m","\x1b[33m","\x1b[34m","\x1b[35m","\x1b[36m","\x1b[37m","\x1b[40m","\x1b[41m","\x1b[42m","\x1b[43m","\x1b[44m","\x1b[45m","\x1b[46m","\x1b[47m","\x1b(B","\x1b[m","\x1b[2m"]
|
||||||
@ -228,7 +252,6 @@ class Plugin:
|
|||||||
p=[]
|
p=[]
|
||||||
for _ in range(len(t[0])):
|
for _ in range(len(t[0])):
|
||||||
r=self.findall(s[t[0][_]:t[1][_]],'\x1b')
|
r=self.findall(s[t[0][_]:t[1][_]],'\x1b')
|
||||||
|
|
||||||
for __ in range(len(r)):
|
for __ in range(len(r)):
|
||||||
if not __ == len(r)-1:
|
if not __ == len(r)-1:
|
||||||
p.append(s[t[0][_]:t[1][_]][r[__]:r[__+1]])
|
p.append(s[t[0][_]:t[1][_]][r[__]:r[__+1]])
|
||||||
@ -250,14 +273,13 @@ class Plugin:
|
|||||||
farthest_color_hex = rgb2set['ef{}'.format(gravity)]
|
farthest_color_hex = rgb2set['ef{}'.format(gravity)]
|
||||||
result = self.hex2gravity(farthest_color_hex)
|
result = self.hex2gravity(farthest_color_hex)
|
||||||
c.append(result)
|
c.append(result)
|
||||||
|
|
||||||
r=self.findall(_s,'{}')
|
r=self.findall(_s,'{}')
|
||||||
|
|
||||||
for _ in range(len(r)):
|
for _ in range(len(r)):
|
||||||
_s=_s.replace('{}',c[_],1)
|
_s=_s.replace('{}',c[_],1)
|
||||||
return _s
|
return _s
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def ratesex(self, mask, target, args):
|
def ratesex(self, mask, target, args):
|
||||||
@ -294,6 +316,7 @@ class Plugin:
|
|||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
|
||||||
__doc__ = ''':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.
|
__doc__ = ''':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.
|
||||||
@ -346,5 +369,6 @@ __doc__ = ''':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|||||||
-ymNNNNNNNNNNNNNNNNNNNNNNNNdo-` +NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmy.
|
-ymNNNNNNNNNNNNNNNNNNNNNNNNdo-` +NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmy.
|
||||||
............................ .-...............................`
|
............................ .-...............................`
|
||||||
`````` ````````` `````````````` `````````` ```'''
|
`````` ````````` `````````````` `````````` ```'''
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,29 +1,43 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
import irc3
|
import irc3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import time
|
from time import time
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
REMIND_RE = re.compile('maple.remind\s(.+?)\s(.+)')
|
REMIND_RE = re.compile('maple.remind\s(.+?)\s(.+)')
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __triggered(i):
|
def __triggered(i):
|
||||||
time_now = int(str(time()).split('.')[0])
|
time_now = int(str(time()).split('.')[0])
|
||||||
if i <= time_now:
|
if i <= time_now:
|
||||||
print('triggered')
|
print('triggered')
|
||||||
else:
|
else:
|
||||||
print('not triggered')
|
print('not triggered')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def on_privmsg_search_for_remind(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_for_remind(self, mask=None, target=None, data=None, **kw):
|
||||||
@ -81,10 +95,10 @@ class Plugin:
|
|||||||
self.bot.db.setlist("remind_%s" % tell_nick.lower(), message_list)
|
self.bot.db.setlist("remind_%s" % tell_nick.lower(), message_list)
|
||||||
irc_message = "TCPDIRECT/REMIND: {} < {} > reminding < {} > {}".format(new_message.get("time"),new_message.get("from"),tell_nick,new_message.get("message"))
|
irc_message = "TCPDIRECT/REMIND: {} < {} > reminding < {} > {}".format(new_message.get("time"),new_message.get("from"),tell_nick,new_message.get("message"))
|
||||||
self.bot.privmsg(target, self.bot.emo(irc_message))
|
self.bot.privmsg(target, self.bot.emo(irc_message))
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@cron('* * * * *')
|
@cron('* * * * *')
|
||||||
def _reminding(bot):
|
def _reminding(bot):
|
||||||
nicks = ','.join(bot.db.context.nicks.keys()).split(',')
|
nicks = ','.join(bot.db.context.nicks.keys()).split(',')
|
||||||
@ -104,6 +118,6 @@ def _reminding(bot):
|
|||||||
else:
|
else:
|
||||||
_keys.append(__)
|
_keys.append(__)
|
||||||
bot.db.setlist("remind_{}".format(_),_keys)
|
bot.db.setlist("remind_{}".format(_),_keys)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,13 +1,39 @@
|
|||||||
# -*- coding: utf-8 -*- ########################################################## SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
import irc3,os,base64
|
###########################################################################################
|
||||||
|
|
||||||
|
import irc3,os,sys,base64
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
######################################################################################
|
from plugins.tool_log_plugin import FOG
|
||||||
BOT_SASL_USERNAME=os.environ['BOT_SASL_USERNAME']
|
|
||||||
BOT_SASL_PASSWORD=os.environ['BOT_SASL_PASSWORD']
|
###########################################################################################
|
||||||
######################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
BOT_SASL_USERNAME=getenv('BOT_SASL_USERNAME')
|
||||||
|
BOT_SASL_PASSWORD=getenv('BOT_SASL_PASSWORD')
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class DR1PSASL:
|
class DR1PSASL:
|
||||||
##################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
print('<<< _sasl_custom_plugin >>> [ custom sasl initiated ]')
|
print('<<< _sasl_custom_plugin >>> [ custom sasl initiated ]')
|
||||||
self.bot=bot
|
self.bot=bot
|
||||||
@ -20,31 +46,46 @@ class DR1PSASL:
|
|||||||
irc3.event(r'AUTHENTICATE +', self.authenticate),
|
irc3.event(r'AUTHENTICATE +', self.authenticate),
|
||||||
irc3.event(r'^:\S+ 903 \S+ :Authentication successful',self.cap_end),
|
irc3.event(r'^:\S+ 903 \S+ :Authentication successful',self.cap_end),
|
||||||
]
|
]
|
||||||
##################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def connection_ready(self, *args, **kwargs):
|
def connection_ready(self, *args, **kwargs):
|
||||||
print('<<< _sasl_custom_plugin >>> [ CAP LS ]')
|
print('<<< _sasl_custom_plugin >>> [ CAP LS ]')
|
||||||
self.bot.send('CAP LS\r\n')
|
self.bot.send('CAP LS\r\n')
|
||||||
self.bot.attach_events(*self.events)
|
self.bot.attach_events(*self.events)
|
||||||
##################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def cap_ls(self, data=None, **kwargs):
|
def cap_ls(self, data=None, **kwargs):
|
||||||
print('<<< _sasl_custom_plugin >>> [ CAP REQ :sasl ]')
|
print('<<< _sasl_custom_plugin >>> [ CAP REQ :sasl ]')
|
||||||
if 'sasl' in data.lower():
|
if 'sasl' in data.lower():
|
||||||
self.bot.send_line('CAP REQ :sasl')
|
self.bot.send_line('CAP REQ :sasl')
|
||||||
else:
|
else:
|
||||||
self.cap_end()
|
self.cap_end()
|
||||||
##################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def cap_ack(self, **kwargs):
|
def cap_ack(self, **kwargs):
|
||||||
print('<<< _sasl_custom_plugin >>> [ AUTHENTICATE PLAIN ]')
|
print('<<< _sasl_custom_plugin >>> [ AUTHENTICATE PLAIN ]')
|
||||||
self.bot.send_line('AUTHENTICATE PLAIN')
|
self.bot.send_line('AUTHENTICATE PLAIN')
|
||||||
##################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def authenticate(self, **kwargs):
|
def authenticate(self, **kwargs):
|
||||||
print(f'<<< _sasl_custom_plugin >>> [ AUTHENTICATE {self.auth} ]')
|
print(f'<<< _sasl_custom_plugin >>> [ AUTHENTICATE {self.auth} ]')
|
||||||
self.bot.send_line(f'AUTHENTICATE {self.auth}\n')
|
self.bot.send_line(f'AUTHENTICATE {self.auth}\n')
|
||||||
##################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def cap_end(self, **kwargs):
|
def cap_end(self, **kwargs):
|
||||||
print('<<< _sasl_custom_plugin >>> [ CAP END ]')
|
print('<<< _sasl_custom_plugin >>> [ CAP END ]')
|
||||||
self.bot.send_line('CAP END\r\n')
|
self.bot.send_line('CAP END\r\n')
|
||||||
self.bot.detach_events(*self.events)
|
self.bot.detach_events(*self.events)
|
||||||
##################################################################################
|
|
||||||
################################################################################## EOF
|
###########################################################################################
|
||||||
#.[d].
|
####################################################################################### EOF
|
||||||
|
@ -1,42 +1,54 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
from string import ascii_lowercase as alpha
|
from string import ascii_lowercase as alpha
|
||||||
SED1_RE = "s/"
|
SED1_RE = "s/"
|
||||||
SED2_RE = "j/"
|
SED2_RE = "j/"
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
class TCPSED():
|
class TCPSED():
|
||||||
buffer_text=[]
|
buffer_text=[]
|
||||||
buffer_nick=[]
|
buffer_nick=[]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def push(self,data,nick):
|
def push(self,data,nick):
|
||||||
self.buffer_text=self.buffer_text[-1:]+self.buffer_text[:-1]
|
self.buffer_text=self.buffer_text[-1:]+self.buffer_text[:-1]
|
||||||
self.buffer_text[0]=data
|
self.buffer_text[0]=data
|
||||||
self.buffer_nick=self.buffer_nick[-1:]+self.buffer_nick[:-1]
|
self.buffer_nick=self.buffer_nick[-1:]+self.buffer_nick[:-1]
|
||||||
self.buffer_nick[0]=nick
|
self.buffer_nick[0]=nick
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.d=TCPSED()
|
self.d=TCPSED()
|
||||||
for _ in range(2000):
|
for _ in range(2000):
|
||||||
self.d.buffer_text.append('')
|
self.d.buffer_text.append('')
|
||||||
self.d.buffer_nick.append('')
|
self.d.buffer_nick.append('')
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_search_for_sed(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_for_sed(self, mask=None, target=None, data=None, **kw):
|
||||||
if self.bot.config.nick == mask.nick:
|
if self.bot.config.nick == mask.nick:
|
||||||
@ -91,7 +103,6 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,self.bot.emo(irc_message))
|
self.bot.privmsg(target,self.bot.emo(irc_message))
|
||||||
except:
|
except:
|
||||||
self.bot.privmsg(target,self.bot.emo(irc_message))
|
self.bot.privmsg(target,self.bot.emo(irc_message))
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,29 +1,39 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import operator
|
import operator
|
||||||
import irc3
|
import irc3
|
||||||
import timeago
|
import timeago
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
return
|
return
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.NEW_NICK)
|
@irc3.event(irc3.rfc.NEW_NICK)
|
||||||
def on_nick_change_for_seen(self, nick, new_nick):
|
def on_nick_change_for_seen(self, nick, new_nick):
|
||||||
|
|
||||||
# record of nickchanges, these are kept
|
# record of nickchanges, these are kept
|
||||||
# "5": {
|
# "5": {
|
||||||
# "msg": "_d changed nick to d",
|
# "msg": "_d changed nick to d",
|
||||||
# "time": "2021-10-03T00:24:03.040916",
|
# "time": "2021-10-03T00:24:03.040916",
|
||||||
# "type": "newnick"
|
# "type": "newnick"
|
||||||
# },
|
# },
|
||||||
|
|
||||||
new_key = "last_msg_for_{}".format(new_nick).lower()
|
new_key = "last_msg_for_{}".format(new_nick).lower()
|
||||||
msg_list = self.bot.db.getlist(new_key)
|
msg_list = self.bot.db.getlist(new_key)
|
||||||
if not msg_list:
|
if not msg_list:
|
||||||
@ -34,8 +44,10 @@ class Plugin:
|
|||||||
msg_list.append(seen_msg)
|
msg_list.append(seen_msg)
|
||||||
self.bot.db.setlist(new_key, msg_list)
|
self.bot.db.setlist(new_key, msg_list)
|
||||||
return
|
return
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_for_seen(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_for_seen(self, mask=None, target=None, data=None, **kw):
|
||||||
if data.startswith("?"): return # no ?
|
if data.startswith("?"): return # no ?
|
||||||
@ -87,8 +99,10 @@ class Plugin:
|
|||||||
messages.append(priv_msg)
|
messages.append(priv_msg)
|
||||||
self.bot.db.setlist(key, messages)
|
self.bot.db.setlist(key, messages)
|
||||||
return
|
return
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def seen(self, mask, target, args):
|
def seen(self, mask, target, args):
|
||||||
"""Display last time user was seen
|
"""Display last time user was seen
|
||||||
@ -123,7 +137,6 @@ class Plugin:
|
|||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
return
|
return
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
###########################################################################################
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
@ -7,16 +9,22 @@ from urllib.parse import quote_plus
|
|||||||
import html
|
import html
|
||||||
import requests
|
import requests
|
||||||
from lxml.html import fromstring
|
from lxml.html import fromstring
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __soundcloud__request(self,command,query):
|
def __soundcloud__request(self,command,query):
|
||||||
USER_AGENT_CURL="curl/7.29.0"
|
USER_AGENT_CURL="curl/7.29.0"
|
||||||
STATUS_BAD_CODE=":( - error code: {}"
|
STATUS_BAD_CODE=":( - error code: {}"
|
||||||
@ -35,8 +43,10 @@ class Plugin:
|
|||||||
return STATUS_BAD_REASON.format(e.reason)
|
return STATUS_BAD_REASON.format(e.reason)
|
||||||
else:
|
else:
|
||||||
return STATUS_OK+response
|
return STATUS_OK+response
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def sc(self, mask, target, args):
|
def sc(self, mask, target, args):
|
||||||
"""Soundcloud artist/song search.. example: ?sc yung innanet nano tapes cronjob
|
"""Soundcloud artist/song search.. example: ?sc yung innanet nano tapes cronjob
|
||||||
@ -72,9 +82,15 @@ class Plugin:
|
|||||||
URL=f'https://soundcloud.com/{_path[0]}'
|
URL=f'https://soundcloud.com/{_path[0]}'
|
||||||
TITLE=title.split('|')[0].split('by')[-1].strip()
|
TITLE=title.split('|')[0].split('by')[-1].strip()
|
||||||
NAME=html.unescape(_name[0]);
|
NAME=html.unescape(_name[0]);
|
||||||
######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK ######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK ########
|
|
||||||
|
######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK <-> SOUNDCLOUD ####################
|
||||||
|
######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK <-> SOUNDCLOUD ####################
|
||||||
|
|
||||||
self.bot.bbs.enter(NICK,URL,TITLE)
|
self.bot.bbs.enter(NICK,URL,TITLE)
|
||||||
######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK ######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK ########
|
|
||||||
|
######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK <-> SOUNDCLOUD ####################
|
||||||
|
######## SOUNDCLOUD <-> BOOMBOX_PLUGIN HOOK <-> SOUNDCLOUD ####################
|
||||||
|
|
||||||
msg=f"\x02\x0302{NICK}\x0F\x02\x0304 > "
|
msg=f"\x02\x0302{NICK}\x0F\x02\x0304 > "
|
||||||
msg+=f"\x0F\x02\x0313{NAME}\x0F\x02\x0304 > "
|
msg+=f"\x0F\x02\x0313{NAME}\x0F\x02\x0304 > "
|
||||||
msg+=f"\x0F\x02\x0312{URL}\x0F\x02\x0313\x0F\x02\x0304 > "
|
msg+=f"\x0F\x02\x0312{URL}\x0F\x02\x0313\x0F\x02\x0304 > "
|
||||||
@ -84,6 +100,6 @@ class Plugin:
|
|||||||
msg=f"\x02\x0302{NICK}\x0F\x02\x0304 > "
|
msg=f"\x02\x0302{NICK}\x0F\x02\x0304 > "
|
||||||
msg+=f"\x0F\x02\x0313{MSG}\x0F\x02\x0304 "
|
msg+=f"\x0F\x02\x0313{MSG}\x0F\x02\x0304 "
|
||||||
self.bot.privmsg(target,self.bot.emo(f"{msg}"))
|
self.bot.privmsg(target,self.bot.emo(f"{msg}"))
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
try:
|
try:
|
||||||
import ujson as json
|
import ujson as json
|
||||||
@ -6,34 +8,65 @@ except ImportError:
|
|||||||
import json
|
import json
|
||||||
import irc3
|
import irc3
|
||||||
import shelve
|
import shelve
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class Shelve:
|
class Shelve:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, uri=None, **kwargs):
|
def __init__(self, uri=None, **kwargs):
|
||||||
self.filename = uri[9:]
|
self.filename = uri[9:]
|
||||||
self.db = shelve.open(self.filename)
|
self.db = shelve.open(self.filename)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
self.db[key] = value
|
self.db[key] = value
|
||||||
self.db.sync()
|
self.db.sync()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
return self.db[key]
|
return self.db[key]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
del self.db[key]
|
del self.db[key]
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def contains(self, key):
|
def contains(self, key):
|
||||||
return key in self.db
|
return key in self.db
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
self.db.sync()
|
self.db.sync()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class JSON:
|
class JSON:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, uri=None, **kwargs):
|
def __init__(self, uri=None, **kwargs):
|
||||||
self.filename = uri[7:]
|
self.filename = uri[7:]
|
||||||
if os.path.isfile(self.filename): # pragma: no cover
|
if os.path.isfile(self.filename): # pragma: no cover
|
||||||
@ -41,39 +74,70 @@ class JSON:
|
|||||||
self.db = json.load(fd)
|
self.db = json.load(fd)
|
||||||
else:
|
else:
|
||||||
self.db = {}
|
self.db = {}
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
self.db[key] = value
|
self.db[key] = value
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
return self.db[key]
|
return self.db[key]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
del self.db[key]
|
del self.db[key]
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def contains(self, key):
|
def contains(self, key):
|
||||||
return key in self.db
|
return key in self.db
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
with open(self.filename, 'w') as fd:
|
with open(self.filename, 'w') as fd:
|
||||||
json.dump(self.db, fd, indent=2, sort_keys=True)
|
json.dump(self.db, fd, indent=2, sort_keys=True)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class Redis:
|
class Redis:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, uri=None, **kwargs):
|
def __init__(self, uri=None, **kwargs):
|
||||||
ConnectionPool = irc3.utils.maybedotted(
|
ConnectionPool = irc3.utils.maybedotted(
|
||||||
'redis.connection.ConnectionPool')
|
'redis.connection.ConnectionPool')
|
||||||
pool = ConnectionPool.from_url(uri)
|
pool = ConnectionPool.from_url(uri)
|
||||||
StrictRedis = irc3.utils.maybedotted('redis.client.StrictRedis')
|
StrictRedis = irc3.utils.maybedotted('redis.client.StrictRedis')
|
||||||
self.db = StrictRedis(connection_pool=pool)
|
self.db = StrictRedis(connection_pool=pool)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
self.db.hmset(key, value)
|
self.db.hmset(key, value)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
keys = self.db.hkeys(key)
|
keys = self.db.hkeys(key)
|
||||||
if not keys:
|
if not keys:
|
||||||
@ -83,22 +147,40 @@ class Redis:
|
|||||||
values = [v.decode('utf8') for v in values]
|
values = [v.decode('utf8') for v in values]
|
||||||
values = dict(zip(keys, values))
|
values = dict(zip(keys, values))
|
||||||
return values
|
return values
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
self.db.delete(key)
|
self.db.delete(key)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def contains(self, key):
|
def contains(self, key):
|
||||||
return self.db.exists(key)
|
return self.db.exists(key)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def flushdb(self):
|
def flushdb(self):
|
||||||
self.db.flushdb()
|
self.db.flushdb()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
self.db.save()
|
self.db.save()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class SQLite:
|
class SQLite:
|
||||||
CREATE_TABLE = """
|
CREATE_TABLE = """
|
||||||
CREATE TABLE IF NOT EXISTS
|
CREATE TABLE IF NOT EXISTS
|
||||||
@ -111,7 +193,10 @@ class SQLite:
|
|||||||
UPSERT = """
|
UPSERT = """
|
||||||
INSERT OR REPLACE INTO irc3_storage(key,value) VALUES(?, ?);
|
INSERT OR REPLACE INTO irc3_storage(key,value) VALUES(?, ?);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, uri=None, **kwargs):
|
def __init__(self, uri=None, **kwargs):
|
||||||
self.sqlite = irc3.utils.maybedotted('sqlite3')
|
self.sqlite = irc3.utils.maybedotted('sqlite3')
|
||||||
self.uri = uri.split('://')[-1]
|
self.uri = uri.split('://')[-1]
|
||||||
@ -120,7 +205,10 @@ class SQLite:
|
|||||||
cursor.execute(self.CREATE_TABLE)
|
cursor.execute(self.CREATE_TABLE)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
conn = self.sqlite.connect(self.uri)
|
conn = self.sqlite.connect(self.uri)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@ -128,7 +216,10 @@ class SQLite:
|
|||||||
cursor.fetchall()
|
cursor.fetchall()
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
value = None
|
value = None
|
||||||
conn = self.sqlite.connect(self.uri)
|
conn = self.sqlite.connect(self.uri)
|
||||||
@ -142,7 +233,10 @@ class SQLite:
|
|||||||
if value is None:
|
if value is None:
|
||||||
raise KeyError(key)
|
raise KeyError(key)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
conn = self.sqlite.connect(self.uri)
|
conn = self.sqlite.connect(self.uri)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@ -150,7 +244,10 @@ class SQLite:
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def contains(self, key):
|
def contains(self, key):
|
||||||
conn = self.sqlite.connect(self.uri)
|
conn = self.sqlite.connect(self.uri)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@ -161,7 +258,10 @@ class SQLite:
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def flushdb(self):
|
def flushdb(self):
|
||||||
conn = self.sqlite.connect(self.uri)
|
conn = self.sqlite.connect(self.uri)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@ -170,13 +270,22 @@ class SQLite:
|
|||||||
cursor.close()
|
cursor.close()
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Storage:
|
class Storage:
|
||||||
backends = {
|
backends = {
|
||||||
@ -187,7 +296,10 @@ class Storage:
|
|||||||
'rediss': Redis,
|
'rediss': Redis,
|
||||||
'sqlite': SQLite,
|
'sqlite': SQLite,
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
uri = context.config.storage
|
uri = context.config.storage
|
||||||
name = uri.split('://', 1)[0]
|
name = uri.split('://', 1)[0]
|
||||||
@ -198,7 +310,10 @@ class Storage:
|
|||||||
self.backend = factory(uri)
|
self.backend = factory(uri)
|
||||||
self.context = context
|
self.context = context
|
||||||
self.context.db = self
|
self.context.db = self
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def setdefault(self, key_, **kwargs):
|
def setdefault(self, key_, **kwargs):
|
||||||
"""Update storage value for key with kwargs iif the keys doesn't
|
"""Update storage value for key with kwargs iif the keys doesn't
|
||||||
exist. Return stored values"""
|
exist. Return stored values"""
|
||||||
@ -213,14 +328,20 @@ class Storage:
|
|||||||
if changed:
|
if changed:
|
||||||
self[key_] = stored
|
self[key_] = stored
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def get(self, key_, default=None):
|
def get(self, key_, default=None):
|
||||||
"""Get storage value for key or return default"""
|
"""Get storage value for key or return default"""
|
||||||
if key_ not in self:
|
if key_ not in self:
|
||||||
return default
|
return default
|
||||||
else:
|
else:
|
||||||
return self[key_]
|
return self[key_]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def getlist(self, key_, default=None):
|
def getlist(self, key_, default=None):
|
||||||
"""Get storage value (as list) for key or return default"""
|
"""Get storage value (as list) for key or return default"""
|
||||||
if key_ not in self:
|
if key_ not in self:
|
||||||
@ -229,7 +350,10 @@ class Storage:
|
|||||||
value = self[key_]
|
value = self[key_]
|
||||||
value = [(int(i), v) for i, v in value.items()]
|
value = [(int(i), v) for i, v in value.items()]
|
||||||
return [v for k, v in sorted(value)]
|
return [v for k, v in sorted(value)]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def set(self, key_, **kwargs):
|
def set(self, key_, **kwargs):
|
||||||
"""Update storage value for key with kwargs"""
|
"""Update storage value for key with kwargs"""
|
||||||
stored = self.get(key_, dict())
|
stored = self.get(key_, dict())
|
||||||
@ -240,14 +364,20 @@ class Storage:
|
|||||||
changed = True
|
changed = True
|
||||||
if changed:
|
if changed:
|
||||||
self[key_] = stored
|
self[key_] = stored
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def setlist(self, key_, value):
|
def setlist(self, key_, value):
|
||||||
"""Update storage value (as list)"""
|
"""Update storage value (as list)"""
|
||||||
value = dict([(str(i), v) for i, v in enumerate(value)])
|
value = dict([(str(i), v) for i, v in enumerate(value)])
|
||||||
if key_ in self:
|
if key_ in self:
|
||||||
del self[key_]
|
del self[key_]
|
||||||
self.set(key_, **value)
|
self.set(key_, **value)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
"""Set storage value for key"""
|
"""Set storage value for key"""
|
||||||
key = getattr(key, '__module__', key)
|
key = getattr(key, '__module__', key)
|
||||||
@ -258,7 +388,10 @@ class Storage:
|
|||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
self.context.log.exception(e)
|
self.context.log.exception(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
"""Get storage value for key"""
|
"""Get storage value for key"""
|
||||||
key = getattr(key, '__module__', key)
|
key = getattr(key, '__module__', key)
|
||||||
@ -269,7 +402,10 @@ class Storage:
|
|||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
self.context.log.exception(e)
|
self.context.log.exception(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
"""Delete key in storage"""
|
"""Delete key in storage"""
|
||||||
key = getattr(key, '__module__', key)
|
key = getattr(key, '__module__', key)
|
||||||
@ -278,7 +414,10 @@ class Storage:
|
|||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
self.context.log.exception(e)
|
self.context.log.exception(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
"""Return True if storage contains key"""
|
"""Return True if storage contains key"""
|
||||||
key = getattr(key, '__module__', key)
|
key = getattr(key, '__module__', key)
|
||||||
@ -287,8 +426,12 @@ class Storage:
|
|||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
self.context.log.exception(e)
|
self.context.log.exception(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def SIGINT(self):
|
def SIGINT(self):
|
||||||
self.backend.close()
|
self.backend.close()
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def _get_weed(self,t,s):
|
def _get_weed(self,t,s):
|
||||||
try:
|
try:
|
||||||
url=""
|
url=""
|
||||||
@ -28,8 +36,10 @@ class Plugin:
|
|||||||
return r.json()
|
return r.json()
|
||||||
except:
|
except:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def strain(self, mask, target, args):
|
def strain(self, mask, target, args):
|
||||||
"""strain
|
"""strain
|
||||||
@ -85,7 +95,6 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
msg = "strain: not found"
|
msg = "strain: not found"
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,15 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################################# SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
import irc3
|
import irc3
|
||||||
import socket
|
import socket
|
||||||
#########################################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
#########################################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
#####################################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def tcpac(self, mask, target, args):
|
def tcpac(self, mask, target, args):
|
||||||
"""tcpac - the irc version of `cat file - | nc tcp.ac 9999`, usage: ?tcpac message
|
"""tcpac - the irc version of `cat file - | nc tcp.ac 9999`, usage: ?tcpac message
|
||||||
@ -28,6 +39,6 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
msg=f"{mask.nick}: irc version of `cat file - | nc tcp.ac 9999` -> del: {delmsg}"
|
msg=f"{mask.nick}: irc version of `cat file - | nc tcp.ac 9999` -> del: {delmsg}"
|
||||||
self.bot.privmsg(mask.nick,msg)
|
self.bot.privmsg(mask.nick,msg)
|
||||||
#####################################################################################################
|
|
||||||
##################################################################################################### EOF
|
###########################################################################################
|
||||||
#.[d].
|
####################################################################################### EOF
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import irc3
|
import irc3
|
||||||
import re
|
import re
|
||||||
TELL_RE = re.compile('maple.tell\s(.+?)\s(.+)')
|
TELL_RE = re.compile('maple.tell\s(.+?)\s(.+)')
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_search_to_tell(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_to_tell(self, mask=None, target=None, data=None, **kw):
|
||||||
if mask.nick.lower() == "maple":
|
if mask.nick.lower() == "maple":
|
||||||
@ -23,8 +31,10 @@ class Plugin:
|
|||||||
irc_message = "TCPDIRECT/TOLD: {} <{}> told <{}> {}".format(msg.get("time"),msg.get("from"),mask.nick,msg.get("message"))
|
irc_message = "TCPDIRECT/TOLD: {} <{}> told <{}> {}".format(msg.get("time"),msg.get("from"),mask.nick,msg.get("message"))
|
||||||
self.bot.privmsg(target, self.bot.emo(irc_message))
|
self.bot.privmsg(target, self.bot.emo(irc_message))
|
||||||
self.bot.db.setlist("tell_%s" % mask.nick.lower(), messages_to_send[1:])
|
self.bot.db.setlist("tell_%s" % mask.nick.lower(), messages_to_send[1:])
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_search_for_tell(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_for_tell(self, mask=None, target=None, data=None, **kw):
|
||||||
match_list = TELL_RE.findall(data)
|
match_list = TELL_RE.findall(data)
|
||||||
@ -40,7 +50,7 @@ class Plugin:
|
|||||||
self.bot.db.setlist("tell_%s" % tell_nick.lower(), message_list)
|
self.bot.db.setlist("tell_%s" % tell_nick.lower(), message_list)
|
||||||
irc_message = "TCPDIRECT/TELL: {} <{}> telling <{}> {}".format(new_message.get("time"),new_message.get("from"),tell_nick,new_message.get("message"))
|
irc_message = "TCPDIRECT/TELL: {} <{}> telling <{}> {}".format(new_message.get("time"),new_message.get("from"),tell_nick,new_message.get("message"))
|
||||||
self.bot.privmsg(target, self.bot.emo(irc_message))
|
self.bot.privmsg(target, self.bot.emo(irc_message))
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -7,12 +9,21 @@ from pytz import common_timezones
|
|||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def timezonediff(self, mask, target, args):
|
def timezonediff(self, mask, target, args):
|
||||||
"""timezonediff - '?timezonediff yourzone theirzone calendar_date theirzone_event_time message' or '?timezonediff yourzone theirzone theirzone_event_time message'
|
"""timezonediff - '?timezonediff yourzone theirzone calendar_date theirzone_event_time message' or '?timezonediff yourzone theirzone theirzone_event_time message'
|
||||||
@ -32,6 +43,9 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
zone2=timezone(noise.split()[1])
|
zone2=timezone(noise.split()[1])
|
||||||
except:
|
except:
|
||||||
@ -43,6 +57,9 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
FLAG_DATE=False
|
FLAG_DATE=False
|
||||||
try:
|
try:
|
||||||
date=noise.split()[2].replace("/","")
|
date=noise.split()[2].replace("/","")
|
||||||
@ -74,6 +91,9 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
pass #with no date set we presume it is implied as an event today from now into the time of then
|
pass #with no date set we presume it is implied as an event today from now into the time of then
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if not FLAG_DATE:
|
if not FLAG_DATE:
|
||||||
try:
|
try:
|
||||||
stime=noise.split()[2]
|
stime=noise.split()[2]
|
||||||
@ -95,6 +115,9 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if not FLAG_DATE:
|
if not FLAG_DATE:
|
||||||
try:
|
try:
|
||||||
smessage=' '.join(noise.split()[3:])
|
smessage=' '.join(noise.split()[3:])
|
||||||
@ -121,6 +144,9 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,self.bot.emo(msg))
|
self.bot.privmsg(target,self.bot.emo(msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
dtf=datetime(int(year),int(month),int(day),int(hour),int(minute))
|
dtf=datetime(int(year),int(month),int(day),int(hour),int(minute))
|
||||||
dtn=datetime.now()
|
dtn=datetime.now()
|
||||||
# zone1=timezone('us/central')
|
# zone1=timezone('us/central')
|
||||||
@ -133,6 +159,9 @@ class Plugin:
|
|||||||
tsz2b=z3.timestamp()
|
tsz2b=z3.timestamp()
|
||||||
timedistance=timeago.format(tsz2b-delta.seconds,tsz2a)
|
timedistance=timeago.format(tsz2b-delta.seconds,tsz2a)
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
if str(timedistance).startswith('in'):
|
if str(timedistance).startswith('in'):
|
||||||
msg = f'i will remind in you {timedistance} in your local timezone of {zone1} about {smessage}'
|
msg = f'i will remind in you {timedistance} in your local timezone of {zone1} about {smessage}'
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
@ -148,4 +177,6 @@ class Plugin:
|
|||||||
else:
|
else:
|
||||||
msg = f'sorry, this time of event is in the past now {timedistance}'
|
msg = f'sorry, this time of event is in the past now {timedistance}'
|
||||||
self.bot.privmsg(target, self.bot.emo(msg))
|
self.bot.privmsg(target, self.bot.emo(msg))
|
||||||
#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,84 +1,179 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???DISCORD???
|
???DISCORD???
|
||||||
???TELEGRAM???
|
???TELEGRAM???
|
||||||
???MATRIX???
|
???MATRIX???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
global matrixbot
|
global matrixbot
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
global bus, dims, ircbot
|
global bus, dims, ircbot
|
||||||
from plugins.tool_dims_plugin import dims
|
from plugins.tool_dims_plugin import dims
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
from random import randint as rint
|
from random import randint as rint
|
||||||
import re
|
import re
|
||||||
regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class BUS:
|
class BUS:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
results=[]
|
results=[]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,bridged_network_roomchans=[]):
|
def __init__(self,bridged_network_roomchans=[]):
|
||||||
self.bridged_network_roomchans=bridged_network_roomchans
|
self.bridged_network_roomchans=bridged_network_roomchans
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
self.matrixbot=guds.memory('matrixbot')
|
self.matrixbot=guds.memory('matrixbot')
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
self.ircbot=guds.memory('ircbot')
|
self.ircbot=guds.memory('ircbot')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def sortnet(self,s):
|
def sortnet(self,s):
|
||||||
if s.startswith('!'):
|
if s.startswith('!'):
|
||||||
return '(m)'
|
return '(m)'
|
||||||
elif s.startswith('#'):
|
elif s.startswith('#'):
|
||||||
return '(i)'
|
return '(i)'
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
async def output(self,netschanroom_src,data):
|
async def output(self,netschanroom_src,data):
|
||||||
from plugins.net_irc_plugin import d_irc_msg
|
from plugins.net_irc_plugin import d_irc_msg
|
||||||
if SERVICES_MATRIX:
|
|
||||||
from plugins.net_matrix_plugin import d_matrix_msg
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
###################
|
||||||
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
|
from plugins.net_matrix_plugin import d_matrix_msg
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
chanroom=netschanroom_src[0]; usernick=netschanroom_src[1]
|
chanroom=netschanroom_src[0]; usernick=netschanroom_src[1]
|
||||||
if type(self.bridged_network_roomchans)==list:
|
if type(self.bridged_network_roomchans)==list:
|
||||||
targets=self.bridged_network_roomchans
|
targets=self.bridged_network_roomchans
|
||||||
for target in targets:
|
for target in targets:
|
||||||
if type(data)==list:
|
if type(data)==list:
|
||||||
|
|
||||||
|
##############################################
|
||||||
if SERVICES_MATRIX and target.startswith('!'):
|
if SERVICES_MATRIX and target.startswith('!'):
|
||||||
|
##############################################
|
||||||
|
|
||||||
for _data in data:
|
for _data in data:
|
||||||
d_matrix_msg(target,regex.sub("",_data))
|
d_matrix_msg(target,regex.sub("",_data))
|
||||||
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',_data)}"
|
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',_data)}"
|
||||||
|
|
||||||
|
############################
|
||||||
elif target.startswith('#'):
|
elif target.startswith('#'):
|
||||||
|
############################
|
||||||
|
|
||||||
for _data in data:
|
for _data in data:
|
||||||
d_irc_msg(target,_data)
|
d_irc_msg(target,_data)
|
||||||
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {_data}'
|
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {_data}'
|
||||||
###########################################################################
|
###########################################################################
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
##############################################
|
||||||
if SERVICES_MATRIX and target.startswith('!'):
|
if SERVICES_MATRIX and target.startswith('!'):
|
||||||
|
##############################################
|
||||||
|
|
||||||
d_matrix_msg(target,regex.sub('',data))
|
d_matrix_msg(target,regex.sub('',data))
|
||||||
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',data)}"
|
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',data)}"
|
||||||
|
|
||||||
|
############################
|
||||||
elif target.startswith('#'):
|
elif target.startswith('#'):
|
||||||
|
############################
|
||||||
|
|
||||||
d_irc_msg(target,data)
|
d_irc_msg(target,data)
|
||||||
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {data}'
|
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {data}'
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
else:
|
else:
|
||||||
target=self.bridged_network_roomchans
|
target=self.bridged_network_roomchans
|
||||||
if type(data)==list:
|
if type(data)==list:
|
||||||
|
|
||||||
|
##############################################
|
||||||
if SERVICES_MATRIX and target.startswith('!'):
|
if SERVICES_MATRIX and target.startswith('!'):
|
||||||
|
##############################################
|
||||||
for _data in data:
|
for _data in data:
|
||||||
d_matrix_msg(target,regex.sub('',_data))
|
d_matrix_msg(target,regex.sub('',_data))
|
||||||
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',_data)}"
|
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',_data)}"
|
||||||
|
|
||||||
|
############################
|
||||||
elif target.startswith('#'):
|
elif target.startswith('#'):
|
||||||
|
############################
|
||||||
|
|
||||||
for msg in data:
|
for msg in data:
|
||||||
d_irc_msg(target,_data)
|
d_irc_msg(target,_data)
|
||||||
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {_data}'
|
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {_data}'
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
##############################################
|
||||||
if SERVICES_MATRIX and target.startswith('!'):
|
if SERVICES_MATRIX and target.startswith('!'):
|
||||||
|
##############################################
|
||||||
|
|
||||||
d_matrix_msg(target,regex.sub('',data))
|
d_matrix_msg(target,regex.sub('',data))
|
||||||
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',data)}"
|
msg=f"<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {regex.sub('',data)}"
|
||||||
|
|
||||||
|
############################
|
||||||
elif target.startswith('#'):
|
elif target.startswith('#'):
|
||||||
|
############################
|
||||||
|
|
||||||
d_irc_msg(target,data)
|
d_irc_msg(target,data)
|
||||||
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {data}'
|
msg=f'<<< ____tool_bus_plugin >>> [ BUS.output ] - {self.sortnet(chanroom)}({chanroom})({usernick})->{self.sortnet(target)}({target}) > {data}'
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
async def input(self,network_chanroom_user_src,user_src,data,verbose_bridge):
|
async def input(self,network_chanroom_user_src,user_src,data,verbose_bridge):
|
||||||
prefix_src=""; maple_dispatch=False
|
prefix_src=""; maple_dispatch=False
|
||||||
network_chanroom_dest=network_chanroom_user_src
|
network_chanroom_dest=network_chanroom_user_src
|
||||||
@ -90,20 +185,43 @@ class BUS:
|
|||||||
elif network_chanroom_user_src.startswith('$'): prefix_src="" #"$t"
|
elif network_chanroom_user_src.startswith('$'): prefix_src="" #"$t"
|
||||||
elif network_chanroom_user_src.startswith('^'): prefix_src="" #"^d"
|
elif network_chanroom_user_src.startswith('^'): prefix_src="" #"^d"
|
||||||
netsrc=network_chanroom_user_src
|
netsrc=network_chanroom_user_src
|
||||||
|
|
||||||
#if prefix_src=="": return
|
#if prefix_src=="": return
|
||||||
|
|
||||||
for network_chanroom_dest in self.bridged_network_roomchans:
|
for network_chanroom_dest in self.bridged_network_roomchans:
|
||||||
from plugins.net_irc_plugin import d_irc_msg
|
from plugins.net_irc_plugin import d_irc_msg
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
from plugins.net_matrix_plugin import d_matrix_msg
|
from plugins.net_matrix_plugin import d_matrix_msg
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
from plugins.net_discord_plugin import d_discord_msg
|
from plugins.net_discord_plugin import d_discord_msg
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
from plugins.net_telegram_plugin import d_telegram_msg
|
from plugins.net_telegram_plugin import d_telegram_msg
|
||||||
|
|
||||||
#################################################################### ROUTER
|
#################################################################### ROUTER
|
||||||
|
#################################################################### ROUTER
|
||||||
|
|
||||||
if type(data)==list:
|
if type(data)==list:
|
||||||
for _data in data:
|
for _data in data:
|
||||||
|
|
||||||
########################################################### TELEGRAM
|
########################################################### TELEGRAM
|
||||||
|
########################################################### TELEGRAM
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('$'):
|
if network_chanroom_dest.startswith('$'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
_data=regex.sub("",_data)
|
_data=regex.sub("",_data)
|
||||||
@ -115,8 +233,14 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=regex.sub("",data)
|
msg=regex.sub("",data)
|
||||||
d_telegram_msg(network_chanroom_dest,msg)
|
d_telegram_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
########################################################### DISCORD
|
########################################################### DISCORD
|
||||||
|
########################################################### DISCORD
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('^'):
|
if network_chanroom_dest.startswith('^'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
_data=regex.sub("",_data)
|
_data=regex.sub("",_data)
|
||||||
@ -128,8 +252,14 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=regex.sub("",data)
|
msg=regex.sub("",data)
|
||||||
d_discord_msg(network_chanroom_dest,msg)
|
d_discord_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
############################################################ MATRIX
|
############################################################ MATRIX
|
||||||
|
############################################################ MATRIX
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('!'):
|
if network_chanroom_dest.startswith('!'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
_data=regex.sub("",_data)
|
_data=regex.sub("",_data)
|
||||||
@ -141,7 +271,10 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=regex.sub("",data)
|
msg=regex.sub("",data)
|
||||||
d_matrix_msg(network_chanroom_dest,msg)
|
d_matrix_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
############################################################### IRC
|
############################################################### IRC
|
||||||
|
############################################################### IRC
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('#'):
|
if network_chanroom_dest.startswith('#'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
_data=regex.sub("",_data)
|
_data=regex.sub("",_data)
|
||||||
@ -153,10 +286,19 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=f'{_data.strip()}'
|
msg=f'{_data.strip()}'
|
||||||
d_irc_msg(network_chanroom_dest,msg)
|
d_irc_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
############################################################# LOCAL
|
############################################################# LOCAL
|
||||||
|
############################################################# LOCAL
|
||||||
|
|
||||||
else:
|
else:
|
||||||
############################################################### TELEGRAM
|
|
||||||
|
############################################################### DISCORD
|
||||||
|
############################################################### DISCORD
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('$'):
|
if network_chanroom_dest.startswith('$'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
data=regex.sub("",data)
|
data=regex.sub("",data)
|
||||||
@ -168,8 +310,14 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=regex.sub("",data)
|
msg=regex.sub("",data)
|
||||||
d_telegram_msg(network_chanroom_dest,msg)
|
d_telegram_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
############################################################### DISCORD
|
############################################################### DISCORD
|
||||||
|
############################################################### DISCORD
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('^'):
|
if network_chanroom_dest.startswith('^'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
data=regex.sub("",data)
|
data=regex.sub("",data)
|
||||||
@ -181,8 +329,14 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=regex.sub("",data)
|
msg=regex.sub("",data)
|
||||||
d_discord_msg(network_chanroom_dest,msg)
|
d_discord_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
################################################################ MATRIX
|
################################################################ MATRIX
|
||||||
|
################################################################ MATRIX
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('!'):
|
if network_chanroom_dest.startswith('!'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
data=regex.sub("",data)
|
data=regex.sub("",data)
|
||||||
@ -194,7 +348,10 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=regex.sub("",data)
|
msg=regex.sub("",data)
|
||||||
d_matrix_msg(network_chanroom_dest,msg)
|
d_matrix_msg(network_chanroom_dest,msg)
|
||||||
|
|
||||||
################################################################### IRC
|
################################################################### IRC
|
||||||
|
################################################################### IRC
|
||||||
|
|
||||||
if network_chanroom_dest.startswith('#'):
|
if network_chanroom_dest.startswith('#'):
|
||||||
if verbose_bridge:
|
if verbose_bridge:
|
||||||
data=regex.sub("",data)
|
data=regex.sub("",data)
|
||||||
@ -206,4 +363,6 @@ class BUS:
|
|||||||
else:
|
else:
|
||||||
msg=f'{data.strip()}'
|
msg=f'{data.strip()}'
|
||||||
d_irc_msg(network_chanroom_dest,msg)
|
d_irc_msg(network_chanroom_dest,msg)
|
||||||
####################################################################################### EOF#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,18 +1,31 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
def rgb(r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m"
|
def rgb(r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m"
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def rgbe():return f"\033[38;2;255;255;255m"
|
def rgbe():return f"\033[38;2;255;255;255m"
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
def rgbt(t='',r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m{t}\033[38;2;255;255;255m"
|
def rgbt(t='',r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m{t}\033[38;2;255;255;255m"
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
def colorform(s):
|
def colorform(s):
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
between_gtlts=s.split(' >>> ')[0].split('<<< ')[1]
|
between_gtlts=s.split(' >>> ')[0].split('<<< ')[1]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
between_brackets=s.split(' >>> [ ')[1].split(' ]')[0]
|
between_brackets=s.split(' >>> [ ')[1].split(' ]')[0]
|
||||||
if s[:-2].endswith(between_brackets):
|
if s[:-2].endswith(between_brackets):
|
||||||
@ -21,18 +34,25 @@ def colorform(s):
|
|||||||
FLAG_A=True
|
FLAG_A=True
|
||||||
except:
|
except:
|
||||||
FLAG_A=True
|
FLAG_A=True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if FLAG_A:
|
if FLAG_A:
|
||||||
everything_past_brackets=s.split(' >>> [ ')[1].split(' ] ')[1]
|
everything_past_brackets=s.split(' >>> [ ')[1].split(' ] ')[1]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
s=f"{rgb(b=255)}<<<{rgb(g=255,b=255)} {between_gtlts} {rgb(b=255)}>>> {rgb(r=255)}"
|
s=f"{rgb(b=255)}<<<{rgb(g=255,b=255)} {between_gtlts} {rgb(b=255)}>>> {rgb(r=255)}"
|
||||||
if between_brackets.startswith('('):
|
if between_brackets.startswith('('):
|
||||||
s+=f"[{rgb(b=255)} {between_brackets} {rgb(r=255)}]"
|
s+=f"[{rgb(b=255)} {between_brackets} {rgb(r=255)}]"
|
||||||
else:
|
else:
|
||||||
s+=f"[{rgb(r=255,g=255)} {between_brackets} {rgb(r=255)}]"
|
s+=f"[{rgb(r=255,g=255)} {between_brackets} {rgb(r=255)}]"
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
maybe_delimited=""
|
maybe_delimited=""
|
||||||
try:
|
try:
|
||||||
if maybe_delimited=="":
|
if maybe_delimited=="":
|
||||||
@ -56,5 +76,6 @@ def colorform(s):
|
|||||||
except:
|
except:
|
||||||
print(s)
|
print(s)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,29 +1,51 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???DISCORD???
|
???DISCORD???
|
||||||
???MATRIX???
|
???MATRIX???
|
||||||
???TELEGRAM???
|
???TELEGRAM???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from plugins.tool_guds_plugin import guds
|
from plugins.tool_guds_plugin import guds
|
||||||
import asyncio
|
import asyncio
|
||||||
global dims
|
global dims
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
class DIMS:
|
class DIMS:
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
class __INIT_MATRIX__:
|
class __INIT_MATRIX__:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
class __INIT_ROOM__:
|
class __INIT_ROOM__:
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
class __INIT_BRIDGE_MATRIX__:
|
class __INIT_BRIDGE_MATRIX__:
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
def __init__(self,room):
|
def __init__(self,room):
|
||||||
self.inbound=[]
|
self.inbound=[]
|
||||||
#self.matrix_rooms_inbound=[]
|
|
||||||
self.outbound=[]
|
self.outbound=[]
|
||||||
#self.irc_channels_inbound=[]
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
def __init__(self,room):
|
def __init__(self,room):
|
||||||
room_flag=False
|
room_flag=False
|
||||||
if len(dir(room))>1:
|
if len(dir(room))>1:
|
||||||
@ -41,19 +63,28 @@ class DIMS:
|
|||||||
'typing_users','unread_highlights','unread_notifications','users']:
|
'typing_users','unread_highlights','unread_notifications','users']:
|
||||||
if room_flag:
|
if room_flag:
|
||||||
exec(f'self.{_}=room.{_}')
|
exec(f'self.{_}=room.{_}')
|
||||||
# print(f"room.{_}->{eval(f'self.{_}')}")
|
|
||||||
self.bridge=self.__INIT_BRIDGE_MATRIX__(room.room_id)
|
self.bridge=self.__INIT_BRIDGE_MATRIX__(room.room_id)
|
||||||
else:
|
else:
|
||||||
exec(f'self.{_}=""')
|
exec(f'self.{_}=""')
|
||||||
self.room_id=room
|
self.room_id=room
|
||||||
self.bridge=self.__INIT_BRIDGE_MATRIX__(room)
|
self.bridge=self.__INIT_BRIDGE_MATRIX__(room)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def __init__(self,room):
|
def __init__(self,room):
|
||||||
self.rooms=[]
|
self.rooms=[]
|
||||||
self.rooms.append(self.__INIT_ROOM__(room))
|
self.rooms.append(self.__INIT_ROOM__(room))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __update_matrix__(self,index,room,bridge=""):
|
def __update_matrix__(self,index,room,bridge=""):
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
for _ in ['canonical_alias','creator','display_name','encrypted',
|
for _ in ['canonical_alias','creator','display_name','encrypted',
|
||||||
'federate','fully_read_marker','gen_avatar_url','history_visibility',
|
'federate','fully_read_marker','gen_avatar_url','history_visibility',
|
||||||
'invited_count','invited_users','is_group','is_named','join_rule',
|
'invited_count','invited_users','is_group','is_named','join_rule',
|
||||||
@ -68,63 +99,111 @@ class DIMS:
|
|||||||
cmdf=f"room.{_}"
|
cmdf=f"room.{_}"
|
||||||
cmdt=f"self.matrix[{index}].rooms[0].{_}"
|
cmdt=f"self.matrix[{index}].rooms[0].{_}"
|
||||||
print(f"literal: room.{_}->self.matrix[{index}].rooms[0].{_} - explicit: {eval(cmdf)}->{eval(cmdt)}")
|
print(f"literal: room.{_}->self.matrix[{index}].rooms[0].{_} - explicit: {eval(cmdf)}->{eval(cmdt)}")
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def ismatrixroom(self,room):
|
def ismatrixroom(self,room):
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
###############################################################################
|
###################
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for index_server,_matrix in enumerate(self.matrix):
|
for index_server,_matrix in enumerate(self.matrix):
|
||||||
for index_room,_room in enumerate(_matrix.rooms):
|
for index_room,_room in enumerate(_matrix.rooms):
|
||||||
if _room.room_id==room:
|
if _room.room_id==room:
|
||||||
return True
|
return True
|
||||||
###############################################################################
|
|
||||||
except: pass
|
except: pass
|
||||||
###############################################################################
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
class __INIT_DISCORD__:
|
class __INIT_DISCORD__:
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
class __INIT_CHANNEL__:
|
class __INIT_CHANNEL__:
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
class __INIT_BRIDGE_DISCORD__:
|
class __INIT_BRIDGE_DISCORD__:
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.inbound=[]
|
self.inbound=[]
|
||||||
self.outbound=[]
|
self.outbound=[]
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.channel=channel
|
self.channel=channel
|
||||||
self.bridge=self.__INIT_BRIDGE_DISCORD__(channel)
|
self.bridge=self.__INIT_BRIDGE_DISCORD__(channel)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.channels=[]
|
self.channels=[]
|
||||||
self.channels.append(self.__INIT_CHANNEL__(channel))
|
self.channels.append(self.__INIT_CHANNEL__(channel))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def isdiscordchannel(self,channel):
|
def isdiscordchannel(self,channel):
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
###############################################################################
|
####################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for index_server,_discord in enumerate(self.discord):
|
for index_server,_discord in enumerate(self.discord):
|
||||||
for index_channel,_channel in enumerate(_discord.channels):
|
for index_channel,_channel in enumerate(_discord.channels):
|
||||||
if _channel.channel==channel:
|
if _channel.channel==channel:
|
||||||
return True
|
return True
|
||||||
###############################################################################
|
|
||||||
except: pass
|
except: pass
|
||||||
###############################################################################
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
class __INIT_TELEGRAM__:
|
class __INIT_TELEGRAM__:
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
class __INIT_GROUP__:
|
class __INIT_GROUP__:
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
class __INIT_BRIDGE_TELEGRAM__:
|
class __INIT_BRIDGE_TELEGRAM__:
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
def __init__(self,group):
|
def __init__(self,group):
|
||||||
self.inbound=[]
|
self.inbound=[]
|
||||||
self.outbound=[]
|
self.outbound=[]
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
def __init__(self,group):
|
def __init__(self,group):
|
||||||
self.group=group
|
self.group=group
|
||||||
self.bridge=self.__INIT_BRIDGE_TELEGRAM__(group)
|
self.bridge=self.__INIT_BRIDGE_TELEGRAM__(group)
|
||||||
@ -132,45 +211,70 @@ class DIMS:
|
|||||||
def __init__(self,group):
|
def __init__(self,group):
|
||||||
self.groups=[]
|
self.groups=[]
|
||||||
self.groups.append(self.__INIT_GROUP__(group))
|
self.groups.append(self.__INIT_GROUP__(group))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def istelegramgroup(self,group):
|
def istelegramgroup(self,group):
|
||||||
###################################################################################
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for index_server,_telegram in enumerate(self.telegram):
|
for index_server,_telegram in enumerate(self.telegram):
|
||||||
for index_group,_group in enumerate(_telegram.groups):
|
for index_group,_group in enumerate(_telegram.groups):
|
||||||
if _group.group==group:
|
if _group.group==group:
|
||||||
return True
|
return True
|
||||||
###############################################################################
|
|
||||||
except: pass
|
except: pass
|
||||||
###############################################################################
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
class __INIT_IRC__:
|
class __INIT_IRC__:
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
class __INIT_CHANNEL__:
|
class __INIT_CHANNEL__:
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
class __INIT_BRIDGE_IRC__:
|
class __INIT_BRIDGE_IRC__:
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.inbound=[]
|
self.inbound=[]
|
||||||
#self.irc_channels_inbound=[]
|
|
||||||
self.outbound=[]
|
self.outbound=[]
|
||||||
#self.matrix_rooms_inbound=[]
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.channel=channel
|
self.channel=channel
|
||||||
self.bridge=self.__INIT_BRIDGE_IRC__(channel)
|
self.bridge=self.__INIT_BRIDGE_IRC__(channel)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __init__(self,channel):
|
def __init__(self,channel):
|
||||||
self.channels=[]
|
self.channels=[]
|
||||||
self.channels.append(self.__INIT_CHANNEL__(channel))
|
self.channels.append(self.__INIT_CHANNEL__(channel))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __update_irc__(self,index,channel,bridge=""):
|
def __update_irc__(self,index,channel,bridge=""):
|
||||||
self.irc[index].channels[0].channel=channel
|
self.irc[index].channels[0].channel=channel
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def isircchannel(self,channel=None,return_index=False):
|
def isircchannel(self,channel=None,return_index=False):
|
||||||
###################################################################################
|
|
||||||
try:
|
try:
|
||||||
for index_server,_irc in enumerate(self.irc):
|
for index_server,_irc in enumerate(self.irc):
|
||||||
for index_channel,_channel in enumerate(_irc.channels):
|
for index_channel,_channel in enumerate(_irc.channels):
|
||||||
@ -178,38 +282,46 @@ class DIMS:
|
|||||||
if return_index:
|
if return_index:
|
||||||
return True,index_server
|
return True,index_server
|
||||||
else:
|
else:
|
||||||
return True
|
return True,-1
|
||||||
###################################################################################
|
|
||||||
except: pass
|
except: pass
|
||||||
###################################################################################
|
return False,-1
|
||||||
return False
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
matrix=[]; irc=[]; telegram=[]; discord=[]; netschanroom=[]; netschanroom_bridged=[];
|
matrix=[]; irc=[]; telegram=[]; discord=[]; netschanroom=[]; netschanroom_bridged=[];
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self,net="",chanroom=""):
|
def __init__(self,net="",chanroom=""):
|
||||||
###################################################################################
|
|
||||||
if not net or not chanroom: return
|
if not net or not chanroom: return
|
||||||
###################################################################################
|
|
||||||
net=net.lower()
|
net=net.lower()
|
||||||
dupe_flag=False
|
dupe_flag=False
|
||||||
###################################################################################
|
|
||||||
|
#####################################
|
||||||
if SERVICES_MATRIX and net=='matrix':
|
if SERVICES_MATRIX and net=='matrix':
|
||||||
|
#####################################
|
||||||
|
|
||||||
for i in range(len(self.matrix)):
|
for i in range(len(self.matrix)):
|
||||||
if self.matrix[i].rooms[0].room_id==chanroom.room_id:
|
if self.matrix[i].rooms[0].room_id==chanroom.room_id:
|
||||||
# print(f'<<< ________dims_plugin >>> [ updating pre-existing matrix room data ]')
|
|
||||||
dupe_flag=True; index=i; self.__update_matrix__(index,chanroom)
|
dupe_flag=True; index=i; self.__update_matrix__(index,chanroom)
|
||||||
if not dupe_flag:
|
if not dupe_flag:
|
||||||
# print(f'<<< ________dims_plugin >>> [ new matrix room data entry ]')
|
|
||||||
self.matrix.append(self.__INIT_MATRIX__(chanroom))
|
self.matrix.append(self.__INIT_MATRIX__(chanroom))
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
elif net=='irc':
|
elif net=='irc':
|
||||||
for i in range(len(self.irc)):
|
for i in range(len(self.irc)):
|
||||||
if self.irc[i].channels[0].channel==chanroom:
|
if self.irc[i].channels[0].channel==chanroom:
|
||||||
# print(f'<<< ________dims_plugin >>> [ updating pre-existing irc channel data ]')
|
|
||||||
dupe_flag=True; index=i; self.__update_irc__(index,chanroom)
|
dupe_flag=True; index=i; self.__update_irc__(index,chanroom)
|
||||||
if not dupe_flag:
|
if not dupe_flag:
|
||||||
# print(f'<<< ________dims_plugin >>> [ new irc channel data entry ]')
|
|
||||||
self.irc.append(self.__INIT_IRC__(chanroom))
|
self.irc.append(self.__INIT_IRC__(chanroom))
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __boot__(self):
|
def __boot__(self):
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
dbnames=["matrixchat","telegramchat","discordchat","ircchat"]
|
dbnames=["matrixchat","telegramchat","discordchat","ircchat"]
|
||||||
@ -217,13 +329,25 @@ class DIMS:
|
|||||||
dbdata=ircbot.db.getlist(dbname)
|
dbdata=ircbot.db.getlist(dbname)
|
||||||
if dbdata:
|
if dbdata:
|
||||||
for entry in dbdata:
|
for entry in dbdata:
|
||||||
|
|
||||||
|
##########################################
|
||||||
if SERVICES_MATRIX and dbname==dbnames[0]:
|
if SERVICES_MATRIX and dbname==dbnames[0]:
|
||||||
|
##########################################
|
||||||
|
|
||||||
if not dims.ismatrixroom(entry[0]):
|
if not dims.ismatrixroom(entry[0]):
|
||||||
self.matrix.append(self.__INIT_MATRIX__(entry[0]))
|
self.matrix.append(self.__INIT_MATRIX__(entry[0]))
|
||||||
|
|
||||||
|
##############################################
|
||||||
elif SERVICES_TELEGRAM and dbname==dbnames[1]:
|
elif SERVICES_TELEGRAM and dbname==dbnames[1]:
|
||||||
|
##############################################
|
||||||
|
|
||||||
if not dims.istelegramgroup(entry[1]):
|
if not dims.istelegramgroup(entry[1]):
|
||||||
self.telegram.append(self.__INIT_TELEGRAM__(entry[1]))
|
self.telegram.append(self.__INIT_TELEGRAM__(entry[1]))
|
||||||
|
|
||||||
|
#############################################
|
||||||
elif SERVICES_DISCORD and dbname==dbnames[2]:
|
elif SERVICES_DISCORD and dbname==dbnames[2]:
|
||||||
|
#############################################
|
||||||
|
|
||||||
if not dims.isdiscordchannel(entry[1]):
|
if not dims.isdiscordchannel(entry[1]):
|
||||||
self.discord.append(self.__INIT_DISCORD__(entry[1]))
|
self.discord.append(self.__INIT_DISCORD__(entry[1]))
|
||||||
discordbot=guds.memory('discordbot')
|
discordbot=guds.memory('discordbot')
|
||||||
@ -231,6 +355,10 @@ class DIMS:
|
|||||||
elif dbname==dbnames[3]:
|
elif dbname==dbnames[3]:
|
||||||
if not dims.isircchannel(entry[0]):
|
if not dims.isircchannel(entry[0]):
|
||||||
self.irc.append(self.__INIT_IRC__(entry[0]))
|
self.irc.append(self.__INIT_IRC__(entry[0]))
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
dbname="chatbridges"
|
dbname="chatbridges"
|
||||||
dbdata=ircbot.db.getlist(dbname)
|
dbdata=ircbot.db.getlist(dbname)
|
||||||
if dbdata:
|
if dbdata:
|
||||||
@ -238,55 +366,108 @@ class DIMS:
|
|||||||
chanroom=entry[0]
|
chanroom=entry[0]
|
||||||
src_outbound=entry[1]
|
src_outbound=entry[1]
|
||||||
dest_inbound=entry[2]
|
dest_inbound=entry[2]
|
||||||
|
|
||||||
|
################################################
|
||||||
if SERVICES_MATRIX and chanroom.startswith('!'):
|
if SERVICES_MATRIX and chanroom.startswith('!'):
|
||||||
|
################################################
|
||||||
|
|
||||||
for _matrix in self.matrix:
|
for _matrix in self.matrix:
|
||||||
for _rooms in _matrix.rooms:
|
for _rooms in _matrix.rooms:
|
||||||
if _rooms.room_id==chanroom:
|
if _rooms.room_id==chanroom:
|
||||||
_rooms.bridge.inbound=src_outbound
|
_rooms.bridge.inbound=src_outbound
|
||||||
_rooms.bridge.outbound=dest_inbound
|
_rooms.bridge.outbound=dest_inbound
|
||||||
|
|
||||||
|
##############################
|
||||||
elif chanroom.startswith('#'):
|
elif chanroom.startswith('#'):
|
||||||
|
##############################
|
||||||
|
|
||||||
for _irc in self.irc:
|
for _irc in self.irc:
|
||||||
for _channels in _irc.channels:
|
for _channels in _irc.channels:
|
||||||
if _channels.channel==chanroom:
|
if _channels.channel==chanroom:
|
||||||
_channels.bridge.inbound=src_outbound
|
_channels.bridge.inbound=src_outbound
|
||||||
_channels.bridge.outbound=dest_inbound
|
_channels.bridge.outbound=dest_inbound
|
||||||
|
|
||||||
|
####################################################
|
||||||
elif SERVICES_TELEGRAM and chanroom.startswith('$'):
|
elif SERVICES_TELEGRAM and chanroom.startswith('$'):
|
||||||
|
####################################################
|
||||||
|
|
||||||
for _telegram in self.telegram:
|
for _telegram in self.telegram:
|
||||||
for _groups in _telegram.groups:
|
for _groups in _telegram.groups:
|
||||||
if _groups.group==chanroom:
|
if _groups.group==chanroom:
|
||||||
_groups.bridge.inbound=src_outbound
|
_groups.bridge.inbound=src_outbound
|
||||||
_groups.bridge.outbound=dest_inbound
|
_groups.bridge.outbound=dest_inbound
|
||||||
|
|
||||||
|
###################################################
|
||||||
elif SERVICES_DISCORD and chanroom.startswith('^'):
|
elif SERVICES_DISCORD and chanroom.startswith('^'):
|
||||||
|
###################################################
|
||||||
|
|
||||||
for _discord in self.discord:
|
for _discord in self.discord:
|
||||||
for _channels in _discord.channels:
|
for _channels in _discord.channels:
|
||||||
if _channels.channel==chanroom:
|
if _channels.channel==chanroom:
|
||||||
_channels.bridge.inbound=src_outbound
|
_channels.bridge.inbound=src_outbound
|
||||||
_channels.bridge.outbound=dest_inbound
|
_channels.bridge.outbound=dest_inbound
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __create__(self,net="",chanroom=""):
|
def __create__(self,net="",chanroom=""):
|
||||||
###################################################################################
|
|
||||||
|
#####################################
|
||||||
if SERVICES_MATRIX and net=='matrix':
|
if SERVICES_MATRIX and net=='matrix':
|
||||||
|
#####################################
|
||||||
|
|
||||||
self.matrix.append(self.__INIT_MATRIX__(chanroom))
|
self.matrix.append(self.__INIT_MATRIX__(chanroom))
|
||||||
###################################################################################
|
|
||||||
|
################
|
||||||
elif net=='irc':
|
elif net=='irc':
|
||||||
|
################
|
||||||
|
|
||||||
self.irc.append(self.__INIT_IRC__(chanroom))
|
self.irc.append(self.__INIT_IRC__(chanroom))
|
||||||
###################################################################################
|
|
||||||
|
#########################################
|
||||||
elif SERVICES_DISCORD and net=='discord':
|
elif SERVICES_DISCORD and net=='discord':
|
||||||
|
#########################################
|
||||||
|
|
||||||
self.discord.append(self.__INIT_DISCORD__(chanroom))
|
self.discord.append(self.__INIT_DISCORD__(chanroom))
|
||||||
###################################################################################
|
|
||||||
|
###########################################
|
||||||
elif SERVICES_TELEGRAM and net=='telegram':
|
elif SERVICES_TELEGRAM and net=='telegram':
|
||||||
|
###########################################
|
||||||
|
|
||||||
self.telegram.append(self.__INIT_TELEGRAM__(chanroom))
|
self.telegram.append(self.__INIT_TELEGRAM__(chanroom))
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __delete__(self,net="",chanroom_index=-1):
|
def __delete__(self,net="",chanroom_index=-1):
|
||||||
###################################################################################
|
|
||||||
if SERVICES_MATRIX and net=='matrix': self.matrix.remove(self.matrix[chanroom_index])
|
#####################################
|
||||||
###################################################################################
|
if SERVICES_MATRIX and net=='matrix':
|
||||||
elif net=='irc': self.irc.remove(self.irc[chanroom_index])
|
#####################################
|
||||||
###################################################################################
|
|
||||||
elif SERVICES_DISCORD and net=='discord': self.discord.remove(self.discord[chanroom_index])
|
self.matrix.remove(self.matrix[chanroom_index])
|
||||||
###################################################################################
|
|
||||||
elif SERVICES_TELEGRAM and net=='telegram': self.telegram.remove(self.telegram[chanroom_index])
|
################
|
||||||
|
elif net=='irc':
|
||||||
|
################
|
||||||
|
|
||||||
|
self.irc.remove(self.irc[chanroom_index])
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
elif SERVICES_DISCORD and net=='discord':
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
self.discord.remove(self.discord[chanroom_index])
|
||||||
|
|
||||||
|
###########################################
|
||||||
|
elif SERVICES_TELEGRAM and net=='telegram':
|
||||||
|
###########################################
|
||||||
|
|
||||||
|
self.telegram.remove(self.telegram[chanroom_index])
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
def blackholes(self,src_blackhole,cmd=None):
|
def blackholes(self,src_blackhole,cmd=None):
|
||||||
self.blackhole=[]
|
self.blackhole=[]
|
||||||
@ -311,7 +492,10 @@ class DIMS:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return self.blackhole
|
return self.blackhole
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
def bridge_routes(self,src_outbound,dest_inbound,cmd=None):
|
def bridge_routes(self,src_outbound,dest_inbound,cmd=None):
|
||||||
err_chan="bot is not in this channel/room/group: {}"
|
err_chan="bot is not in this channel/room/group: {}"
|
||||||
@ -319,7 +503,6 @@ class DIMS:
|
|||||||
err_cmds="wrong command given to bridge_routes: {}"
|
err_cmds="wrong command given to bridge_routes: {}"
|
||||||
err_flow="wrong flow direction given: {}"
|
err_flow="wrong flow direction given: {}"
|
||||||
err_same="src_outbound: {} and dest_inbound: {} are the same route"
|
err_same="src_outbound: {} and dest_inbound: {} are the same route"
|
||||||
###################################################################################
|
|
||||||
if src_outbound==dest_inbound: return False,err_same.format(src_outbound,dest_inbound)
|
if src_outbound==dest_inbound: return False,err_same.format(src_outbound,dest_inbound)
|
||||||
try:
|
try:
|
||||||
for flow in ["out","in"]:
|
for flow in ["out","in"]:
|
||||||
@ -327,8 +510,11 @@ class DIMS:
|
|||||||
flow_direction=src_outbound
|
flow_direction=src_outbound
|
||||||
elif flow=="in":
|
elif flow=="in":
|
||||||
flow_direction=dest_inbound
|
flow_direction=dest_inbound
|
||||||
###############################################################################
|
|
||||||
|
######################################################
|
||||||
if SERVICES_MATRIX and flow_direction.startswith('!'):
|
if SERVICES_MATRIX and flow_direction.startswith('!'):
|
||||||
|
######################################################
|
||||||
|
|
||||||
if not dims.ismatrixroom(flow_direction): return False,err_chan.format(flow_direction)
|
if not dims.ismatrixroom(flow_direction): return False,err_chan.format(flow_direction)
|
||||||
for _matrix in self.matrix:
|
for _matrix in self.matrix:
|
||||||
for _rooms in _matrix.rooms:
|
for _rooms in _matrix.rooms:
|
||||||
@ -353,8 +539,11 @@ class DIMS:
|
|||||||
return False,err_flow
|
return False,err_flow
|
||||||
else:
|
else:
|
||||||
return False,err_cmds
|
return False,err_cmds
|
||||||
###################################################################################
|
|
||||||
|
####################################
|
||||||
elif flow_direction.startswith('#'):
|
elif flow_direction.startswith('#'):
|
||||||
|
####################################
|
||||||
|
|
||||||
if not dims.isircchannel(flow_direction): return False,err_chan.format(flow_direction)
|
if not dims.isircchannel(flow_direction): return False,err_chan.format(flow_direction)
|
||||||
for _irc in self.irc:
|
for _irc in self.irc:
|
||||||
for _channels in _irc.channels:
|
for _channels in _irc.channels:
|
||||||
@ -379,8 +568,11 @@ class DIMS:
|
|||||||
return False,err_flow
|
return False,err_flow
|
||||||
else:
|
else:
|
||||||
return False,err_cmds
|
return False,err_cmds
|
||||||
###################################################################################
|
|
||||||
|
##########################################################
|
||||||
elif SERVICES_TELEGRAM and flow_direction.startswith('$'):
|
elif SERVICES_TELEGRAM and flow_direction.startswith('$'):
|
||||||
|
##########################################################
|
||||||
|
|
||||||
if not dims.istelegramgroup(flow_direction): return False,err_chan.format(flow_direction)
|
if not dims.istelegramgroup(flow_direction): return False,err_chan.format(flow_direction)
|
||||||
for _telegram in self.telegram:
|
for _telegram in self.telegram:
|
||||||
for _groups in _telegram.groups:
|
for _groups in _telegram.groups:
|
||||||
@ -405,8 +597,11 @@ class DIMS:
|
|||||||
return False,err_flow
|
return False,err_flow
|
||||||
else:
|
else:
|
||||||
return False,err_cmds
|
return False,err_cmds
|
||||||
###################################################################################
|
|
||||||
|
#########################################################
|
||||||
elif SERVICES_DISCORD and flow_direction.startswith('^'):
|
elif SERVICES_DISCORD and flow_direction.startswith('^'):
|
||||||
|
#########################################################
|
||||||
|
|
||||||
if not dims.isdiscordchannel(flow_direction): return False,err_chan.format(flow_direction)
|
if not dims.isdiscordchannel(flow_direction): return False,err_chan.format(flow_direction)
|
||||||
for _discord in self.discord:
|
for _discord in self.discord:
|
||||||
for _channels in _discord.channels:
|
for _channels in _discord.channels:
|
||||||
@ -431,7 +626,10 @@ class DIMS:
|
|||||||
return False,err_flow
|
return False,err_flow
|
||||||
else:
|
else:
|
||||||
return False,err_cmds
|
return False,err_cmds
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
self.ircbot=guds.memory('ircbot')
|
self.ircbot=guds.memory('ircbot')
|
||||||
self.dbname="chatbridges"
|
self.dbname="chatbridges"
|
||||||
self.db=self.ircbot.db.getlist(self.dbname)
|
self.db=self.ircbot.db.getlist(self.dbname)
|
||||||
@ -475,7 +673,10 @@ class DIMS:
|
|||||||
return True,None
|
return True,None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False,e
|
return False,e
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
def list_channels_bridged(self,netsrc=False):
|
def list_channels_bridged(self,netsrc=False):
|
||||||
self.netschanroom_bridged=[]
|
self.netschanroom_bridged=[]
|
||||||
@ -486,7 +687,11 @@ class DIMS:
|
|||||||
[self.netschanroom_bridged.append(x) for x in _channels.bridge.outbound]
|
[self.netschanroom_bridged.append(x) for x in _channels.bridge.outbound]
|
||||||
else:
|
else:
|
||||||
self.netschanroom_bridged.append([_channels.channel,_channels.bridge.inbound,_channels.bridge.outbound])
|
self.netschanroom_bridged.append([_channels.channel,_channels.bridge.inbound,_channels.bridge.outbound])
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
for _matrix in self.matrix:
|
for _matrix in self.matrix:
|
||||||
for _rooms in _matrix.rooms:
|
for _rooms in _matrix.rooms:
|
||||||
if netsrc:
|
if netsrc:
|
||||||
@ -494,7 +699,11 @@ class DIMS:
|
|||||||
[self.netschanroom_bridged.append(x) for x in _rooms.bridge.outbound]
|
[self.netschanroom_bridged.append(x) for x in _rooms.bridge.outbound]
|
||||||
else:
|
else:
|
||||||
self.netschanroom_bridged.append([_rooms.room_id,_rooms.bridge.inbound,_rooms.bridge.outbound])
|
self.netschanroom_bridged.append([_rooms.room_id,_rooms.bridge.inbound,_rooms.bridge.outbound])
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
for _telegram in self.telegram:
|
for _telegram in self.telegram:
|
||||||
for _groups in _telegram.groups:
|
for _groups in _telegram.groups:
|
||||||
if netsrc:
|
if netsrc:
|
||||||
@ -502,7 +711,11 @@ class DIMS:
|
|||||||
[self.netschanroom_bridged.append(x) for x in _groups.bridge.outbound]
|
[self.netschanroom_bridged.append(x) for x in _groups.bridge.outbound]
|
||||||
else:
|
else:
|
||||||
self.netschanroom_bridged.append([_groups.group,_groups.bridge.inbound,_groups.bridge.outbound])
|
self.netschanroom_bridged.append([_groups.group,_groups.bridge.inbound,_groups.bridge.outbound])
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
for _discord in self.discord:
|
for _discord in self.discord:
|
||||||
for _channels in _discord.channels:
|
for _channels in _discord.channels:
|
||||||
if netsrc:
|
if netsrc:
|
||||||
@ -511,25 +724,39 @@ class DIMS:
|
|||||||
else:
|
else:
|
||||||
self.netschanroom_bridged.append([_channels.channel,_channels.bridge.inbound,_channels.bridge.outbound])
|
self.netschanroom_bridged.append([_channels.channel,_channels.bridge.inbound,_channels.bridge.outbound])
|
||||||
return self.netschanroom_bridged
|
return self.netschanroom_bridged
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='admin', public=False, show_in_help_list=False)
|
@command(permission='admin', public=False, show_in_help_list=False)
|
||||||
def list_channels(self):
|
def list_channels(self):
|
||||||
###################################################################################
|
|
||||||
self.netschanroom=[]
|
self.netschanroom=[]
|
||||||
ircbot=guds.memory('ircbot')
|
ircbot=guds.memory('ircbot')
|
||||||
|
|
||||||
|
###################
|
||||||
if SERVICES_MATRIX:
|
if SERVICES_MATRIX:
|
||||||
|
###################
|
||||||
|
|
||||||
dbname="matrixchat"
|
dbname="matrixchat"
|
||||||
db=ircbot.db.getlist(dbname)
|
db=ircbot.db.getlist(dbname)
|
||||||
if db:
|
if db:
|
||||||
for entry in db:
|
for entry in db:
|
||||||
self.netschanroom.append(entry[0])
|
self.netschanroom.append(entry[0])
|
||||||
|
|
||||||
|
#####################
|
||||||
if SERVICES_TELEGRAM:
|
if SERVICES_TELEGRAM:
|
||||||
|
#####################
|
||||||
|
|
||||||
dbname="telegramchat"
|
dbname="telegramchat"
|
||||||
db=ircbot.db.getlist(dbname)
|
db=ircbot.db.getlist(dbname)
|
||||||
if db:
|
if db:
|
||||||
for entry in db:
|
for entry in db:
|
||||||
self.netschanroom.append(entry[1])
|
self.netschanroom.append(entry[1])
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_DISCORD:
|
if SERVICES_DISCORD:
|
||||||
|
####################
|
||||||
|
|
||||||
dbname="discordchat"
|
dbname="discordchat"
|
||||||
db=ircbot.db.getlist(dbname)
|
db=ircbot.db.getlist(dbname)
|
||||||
if db:
|
if db:
|
||||||
@ -540,8 +767,16 @@ class DIMS:
|
|||||||
if db:
|
if db:
|
||||||
for entry in db:
|
for entry in db:
|
||||||
self.netschanroom.append(entry[0])
|
self.netschanroom.append(entry[0])
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
return self.netschanroom
|
return self.netschanroom
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
dims=DIMS()
|
dims=DIMS()
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
@ -1,17 +1,31 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import timeago
|
import timeago
|
||||||
from plugins.tool_colors_plugin import colorform as print
|
from plugins.tool_colors_plugin import colorform as print
|
||||||
global guds # global unified data system 2 move instantiated data between processes/threads
|
global guds # global unified data system 2 move instantiated data between processes/threads
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
class GUDS:
|
class GUDS:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
push_index=0; memories=[]; timestamped_alarm=[];
|
push_index=0; memories=[]; timestamped_alarm=[];
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def timestamp_alarm(self,reason,seconds):
|
def timestamp_alarm(self,reason,seconds):
|
||||||
try:
|
try:
|
||||||
iseconds=int(seconds)
|
iseconds=int(seconds)
|
||||||
@ -21,7 +35,10 @@ class GUDS:
|
|||||||
print(f'<<< ________guds_plugin >>> [ timestamp_alarm ] - active: {reason} - alarm: {timestamp} - now: {datetime.now().timestamp()}')
|
print(f'<<< ________guds_plugin >>> [ timestamp_alarm ] - active: {reason} - alarm: {timestamp} - now: {datetime.now().timestamp()}')
|
||||||
except:
|
except:
|
||||||
print('<<< ________guds_plugin >>> [ timestamp_alarm ] - error')
|
print('<<< ________guds_plugin >>> [ timestamp_alarm ] - error')
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def timestamp_check(self,reason):
|
def timestamp_check(self,reason):
|
||||||
try:
|
try:
|
||||||
REASON_FLAG=True
|
REASON_FLAG=True
|
||||||
@ -48,16 +65,27 @@ class GUDS:
|
|||||||
except:
|
except:
|
||||||
print('<<< ________guds_plugin >>> [ timestamp_check ] timestamp_check error')
|
print('<<< ________guds_plugin >>> [ timestamp_check ] timestamp_check error')
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def memory(self,data):
|
def memory(self,data):
|
||||||
for _ in self.memories:
|
for _ in self.memories:
|
||||||
if not _[1].find(data)==-1:
|
if not _[1].find(data)==-1:
|
||||||
return _[0]
|
return _[0]
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def push(self,data):
|
def push(self,data):
|
||||||
self.push_index+=1
|
self.push_index+=1
|
||||||
self.memories.append(data)
|
self.memories.append(data)
|
||||||
print(f'<<< ________guds_plugin >>> [ data pushed into guds.memories[{str(self.push_index)}]={guds.memories[-1]} ]')
|
print(f'<<< ________guds_plugin >>> [ data pushed into guds.memories[{str(self.push_index)}]={guds.memories[-1]} ]')
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
guds=GUDS()
|
guds=GUDS()
|
||||||
####################################################################################### EOF#.[d].
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
92
storage/bot/plugins/tool_log_plugin.py
Normal file
92
storage/bot/plugins/tool_log_plugin.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# -*- coding: utf-8 -*- ################################################ SOF - HYDRA LOGGER
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
import sys,inspect
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
class FOG:
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
###################################### - RGB // RETURNS RGB TERMINAL ESCAPE COLOR CODES
|
||||||
|
|
||||||
|
def rgb(self,r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m"
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
##################################################### - FOG // RETURNS FORMATTED STRING
|
||||||
|
|
||||||
|
def fog(self=None,data=None,caller=None,self_name=None):
|
||||||
|
frame = inspect.currentframe().f_back
|
||||||
|
try:
|
||||||
|
codeobj = frame.f_code
|
||||||
|
try:
|
||||||
|
self_name = codeobj.co_varnames[0]
|
||||||
|
except IndexError:
|
||||||
|
caller = None
|
||||||
|
raise Exception()
|
||||||
|
try:
|
||||||
|
self_obj = frame.f_locals[self_name]
|
||||||
|
except KeyError:
|
||||||
|
caller = None
|
||||||
|
raise Exception()
|
||||||
|
self_type = type(self_obj)
|
||||||
|
func_name = codeobj.co_name
|
||||||
|
for cls in self_type.__mro__:
|
||||||
|
try:
|
||||||
|
method = vars(cls)[func_name]
|
||||||
|
except KeyError:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
method = inspect.unwrap(method)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if getattr(method, '__code__', None) is codeobj:
|
||||||
|
caller = self_type.__name__
|
||||||
|
raise Exception()
|
||||||
|
caller = None
|
||||||
|
raise Exception()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
del frame
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
|
PATHFILENAME=sys._getframe().f_code.co_filename
|
||||||
|
filename=PATHFILENAME.split('/')[-1].split('.')[0]
|
||||||
|
renamed="_"*(19-len(filename))+filename
|
||||||
|
the_origin=origin=renamed
|
||||||
|
the_caller=sys._getframe(1).f_code.co_name
|
||||||
|
the_function=sys._getframe().f_code.co_name
|
||||||
|
msg=f'{self.rgb(b=255)}<<<{self.rgb(g=255,b=255)} {the_origin} {self.rgb(b=255)}>>> '
|
||||||
|
if self and data and caller:
|
||||||
|
the_class=""
|
||||||
|
the_class=type(self).__name__
|
||||||
|
if codeobj.co_filename==PATHFILENAME:
|
||||||
|
msg+=f'{self.rgb(r=255)}[ {self.rgb(r=255,b=255)}{caller}.{the_class}.{the_caller} {self.rgb(r=255)}]'
|
||||||
|
else:
|
||||||
|
origin=codeobj.co_filename.split('/')[-1].replace('.py','')
|
||||||
|
msg+=f'{self.rgb(r=255)}[ {self.rgb(r=255,b=255)}{origin}.{the_caller}.{caller}.{__name__}.{the_class}.{the_function} {self.rgb(r=255)}]'
|
||||||
|
msg+=f'{self.rgb(b=255)} - '
|
||||||
|
msg+=f'{self.rgb(g=128,b=128,r=128)}{data}'
|
||||||
|
else:
|
||||||
|
caller=str(self).split(f'<{__name__}.')[1].split()[0]
|
||||||
|
if not self_name and the_caller=="<module>":
|
||||||
|
if codeobj.co_filename==PATHFILENAME:
|
||||||
|
msg+=f'{self.rgb(r=255)}[ {self.rgb(r=255,b=255)}{__name__}.{caller}.{the_function} {self.rgb(r=255)}]'
|
||||||
|
else:
|
||||||
|
origin=codeobj.co_filename.split('/')[-1].replace('.py','')
|
||||||
|
msg+=f'{self.rgb(r=255)}[ {self.rgb(r=255,b=255)}{origin}.{__name__}.{caller}.{the_function} {self.rgb(r=255)}]'
|
||||||
|
else:
|
||||||
|
if codeobj.co_filename==PATHFILENAME:
|
||||||
|
msg+=f'{self.rgb(r=255)}[ {self.rgb(r=255,b=255)}{self_name}.{the_caller}.{caller}.{the_function} {self.rgb(r=255)}]'
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
msg+=f'{self.rgb(b=255)} - '
|
||||||
|
msg+=f'{self.rgb(g=128,b=128,r=128)}{data}'
|
||||||
|
print(msg)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
@ -1,56 +1,95 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???YOUTUBE???
|
???YOUTUBE???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import twitter
|
import twitter
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import timeago
|
import timeago
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
from lxml.html import fromstring
|
from lxml.html import fromstring
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
try:
|
|
||||||
TWITTER_CONSUMER_KEY = os.environ['TWITTER_CONSUMER_KEY']
|
####################
|
||||||
TWITTER_CONSUMER_SECRET = os.environ['TWITTER_CONSUMER_SECRET']
|
|
||||||
TWITTER_ACCESS_TOKEN_KEY = os.environ['TWITTER_ACCESS_TOKEN_KEY']
|
|
||||||
TWITTER_ACCESS_TOKEN_SECRET = os.environ['TWITTER_ACCESS_TOKEN_SECRET']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
TOO_LONG = 2000
|
|
||||||
###########################################################################################
|
|
||||||
###########################################################################################
|
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
try:
|
|
||||||
TWITTER_REGEX = re.compile('https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$', re.IGNORECASE)
|
def getenv(s):
|
||||||
URL_REGEX = re.compile('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', re.IGNORECASE)
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
TWITTER_CONSUMER_KEY = getenv('TWITTER_CONSUMER_KEY')
|
||||||
|
TWITTER_CONSUMER_SECRET = getenv('TWITTER_CONSUMER_SECRET')
|
||||||
|
TWITTER_ACCESS_TOKEN_KEY = getenv('TWITTER_ACCESS_TOKEN_KEY')
|
||||||
|
TWITTER_ACCESS_TOKEN_SECRET = getenv('TWITTER_ACCESS_TOKEN_SECRET')
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
twitter = twitter.Api(consumer_key=TWITTER_CONSUMER_KEY, consumer_secret=TWITTER_CONSUMER_SECRET,
|
twitter = twitter.Api(consumer_key=TWITTER_CONSUMER_KEY, consumer_secret=TWITTER_CONSUMER_SECRET,
|
||||||
access_token_key=TWITTER_ACCESS_TOKEN_KEY, access_token_secret=TWITTER_ACCESS_TOKEN_SECRET)
|
access_token_key=TWITTER_ACCESS_TOKEN_KEY, access_token_secret=TWITTER_ACCESS_TOKEN_SECRET)
|
||||||
except:
|
|
||||||
pass
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
TWITTER_REGEX = re.compile('https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$', re.IGNORECASE)
|
||||||
|
URL_REGEX = re.compile('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', re.IGNORECASE)
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
TOO_LONG = 2000
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def _similar(self, a, b):
|
def _similar(self, a, b):
|
||||||
return SequenceMatcher(None, a, b).ratio()
|
return SequenceMatcher(None, a, b).ratio()
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def _check_for_url(self, og_tweet, d_nick, d_url, d_unrolled, d_text, d_target):
|
def _check_for_url(self, og_tweet, d_nick, d_url, d_unrolled, d_text, d_target):
|
||||||
match_list = URL_REGEX.findall(d_unrolled)
|
match_list = URL_REGEX.findall(d_unrolled)
|
||||||
@ -119,8 +158,10 @@ class Plugin:
|
|||||||
self.bot.privmsg("_debug_check_for_url_error: {}".format(e))
|
self.bot.privmsg("_debug_check_for_url_error: {}".format(e))
|
||||||
print("original: {} nick: {} url: {} unrolled: {} text: {} error: {}".format(og_tweet,d_nick,d_url,d_unrolled,d_text,e))
|
print("original: {} nick: {} url: {} unrolled: {} text: {} error: {}".format(og_tweet,d_nick,d_url,d_unrolled,d_text,e))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def _check_for_twitter(self, mask=None, data=None, target=None, **kw):
|
def _check_for_twitter(self, mask=None, data=None, target=None, **kw):
|
||||||
match_list = TWITTER_REGEX.findall(data)
|
match_list = TWITTER_REGEX.findall(data)
|
||||||
if match_list:
|
if match_list:
|
||||||
@ -161,17 +202,18 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
print('cant remove from matchlist, does not exist')
|
print('cant remove from matchlist, does not exist')
|
||||||
t_eurl = tweet.urls[y].expanded_url
|
t_eurl = tweet.urls[y].expanded_url
|
||||||
###################################################
|
|
||||||
###################################################
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
yt_match_list = YOUTUBE_REGEX.findall(t_eurl)
|
yt_match_list = YOUTUBE_REGEX.findall(t_eurl)
|
||||||
if SERVICES_YOUTUBE and yt_match_list:
|
if yt_match_list:
|
||||||
d_video_id = t_eurl.split('=')[1]
|
d_video_id = t_eurl.split('=')[1]
|
||||||
self.bot.madjust = "{}:UNROLLED".format(user)
|
self.bot.madjust = "{}:UNROLLED".format(user)
|
||||||
self.bot.yt(mask,target,{'<keyword>': [d_video_id],'yt': True})
|
self.bot.yt(mask,target,{'<keyword>': [d_video_id],'yt': True})
|
||||||
self.bot.madjust = ""
|
self.bot.madjust = ""
|
||||||
###################################################
|
|
||||||
###################################################
|
|
||||||
else:
|
else:
|
||||||
if not str(tweet.id) == t_eurl.split('/')[-1]:
|
if not str(tweet.id) == t_eurl.split('/')[-1]:
|
||||||
self.bot._check_for_url(tweet,user,t_turl,t_eurl,tweet_text,target)
|
self.bot._check_for_url(tweet,user,t_turl,t_eurl,tweet_text,target)
|
||||||
@ -199,13 +241,15 @@ class Plugin:
|
|||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_search_for_twitter(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_for_twitter(self, mask=None, target=None, data=None, **kw):
|
||||||
if data.startswith("?"): return
|
if data.startswith("?"): return
|
||||||
if mask.nick.lower() not in self.bot.ignore_list:
|
if mask.nick.lower() not in self.bot.ignore_list:
|
||||||
self._check_for_twitter(mask, data, target)
|
self._check_for_twitter(mask, data, target)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF#.[d].
|
####################################################################################### EOF
|
||||||
|
@ -1,71 +1,109 @@
|
|||||||
# -*- coding: utf-8 -*- ###############################################################MMMMMMMMMMMMMMMMMMM## SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import pdb
|
import pdb
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
import irc3
|
import irc3
|
||||||
import subprocess
|
import subprocess
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||||
import base64
|
import base64
|
||||||
import io
|
import io
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.plugins.cron import cron
|
from irc3.plugins.cron import cron
|
||||||
from PIL import Image, PngImagePlugin
|
from PIL import Image, PngImagePlugin
|
||||||
|
|
||||||
from plugins.tool_log_plugin import cog, dog
|
from plugins.tool_log_plugin import cog, dog
|
||||||
|
|
||||||
################################################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
#ansi_home=os.environ['ANSI_HOME']
|
#ansi_home=os.environ['ANSI_HOME']
|
||||||
#hydrachan=home=os.environ['HYDRA_TEST_CHANNEL']
|
#hydrachan=home=os.environ['HYDRA_TEST_CHANNEL']
|
||||||
################################################################################################################ . GLOBALS PROTOS
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
#global REASSEMBLY
|
#global REASSEMBLY
|
||||||
################################################################################################################ . GLOBALS DATA
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
#REASSEMBLY="1B5B306D"
|
#REASSEMBLY="1B5B306D"
|
||||||
#regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
#regex=re.compile("\x03(?:\d{1,2}(?:,\d{1,2})?)?",re.UNICODE)
|
||||||
################################################################################################################ . FORMATTING STRING COLORS
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
DREY="\x02\x0315"
|
DREY="\x02\x0315"
|
||||||
GREY="\x02\x0314"
|
GREY="\x02\x0314"
|
||||||
DRED="\x02\x0302"
|
DRED="\x02\x0302"
|
||||||
LRED="\x02\x0312"
|
LRED="\x02\x0312"
|
||||||
################################################################################################################ . DEBUGGING - TEST FILE DATA
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
DIRPATH=os.path.dirname(os.path.realpath(__file__))
|
DIRPATH=os.path.dirname(os.path.realpath(__file__))
|
||||||
#IN__FILE__UTF8_IRC_ARTWORK_TXT="" # f"{DIRPATH}/art.txt"
|
#IN__FILE__UTF8_IRC_ARTWORK_TXT="" # f"{DIRPATH}/art.txt"
|
||||||
#OUT_FILE_CP437_ANS_ARTWORK_BIN="" # f"{DIRPATH}/art.ans"
|
#OUT_FILE_CP437_ANS_ARTWORK_BIN="" # f"{DIRPATH}/art.ans"
|
||||||
################################################################################################################ deconcatenation of as tring by specific widths
|
|
||||||
def chunk(s,n): # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
||||||
###############
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
def chunk(s,n):
|
||||||
result=[s[i:i+n] for i in range(0,len(s),n)]
|
result=[s[i:i+n] for i in range(0,len(s),n)]
|
||||||
#############
|
|
||||||
return result
|
return result
|
||||||
################################################################################################################ find every instance of a string within a string
|
|
||||||
def findall(s,w): # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
###########################################################################################
|
||||||
#################
|
###########################################################################################
|
||||||
|
|
||||||
|
def findall(s,w):
|
||||||
result=[i for i in range(len(s)) if s.startswith(w, i)]
|
result=[i for i in range(len(s)) if s.startswith(w, i)]
|
||||||
#############
|
|
||||||
return result
|
return result
|
||||||
################################################################################################################ used to make sure a string fits into a space
|
|
||||||
def padding(s,n): # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
###########################################################################################
|
||||||
#################
|
###########################################################################################
|
||||||
|
|
||||||
|
def padding(s,n):
|
||||||
pad=n-len(s);
|
pad=n-len(s);
|
||||||
padding=(" "*pad);
|
padding=(" "*pad);
|
||||||
s+=padding;
|
s+=padding;
|
||||||
########
|
|
||||||
return s
|
return s
|
||||||
################################################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
############################################################################################################
|
|
||||||
############################################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
########################
|
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.url = "https://saizer:7860"
|
self.url = "https://saizer:7860"
|
||||||
self.models=[]
|
self.models=[]
|
||||||
@ -79,11 +117,12 @@ class Plugin:
|
|||||||
self.height=768
|
self.height=768
|
||||||
self.restore_faces=True
|
self.restore_faces=True
|
||||||
self.running=False
|
self.running=False
|
||||||
############################################################################################################
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view',show_in_help_list=True,error_format="{cmd} error - usage: ?{cmd} clear,default,list,show,set,run - example: ?{cmd} set prompt neon female hacker".format)
|
@command(permission='view',show_in_help_list=True,error_format="{cmd} error - usage: ?{cmd} clear,default,list,show,set,run - example: ?{cmd} set prompt neon female hacker".format)
|
||||||
###################################################
|
|
||||||
def txt2img(self, mask, target, args):
|
def txt2img(self, mask, target, args):
|
||||||
####################################
|
|
||||||
"""txt2img
|
"""txt2img
|
||||||
%%txt2img [<noise>] [<param>] [<paramvalue>]...
|
%%txt2img [<noise>] [<param>] [<paramvalue>]...
|
||||||
"""
|
"""
|
||||||
@ -93,9 +132,7 @@ class Plugin:
|
|||||||
msg="error - usage: ^txt2img default,list,show,set,run - example: ?txt2img set prompt neon female hacker"
|
msg="error - usage: ^txt2img default,list,show,set,run - example: ?txt2img set prompt neon female hacker"
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
return
|
return
|
||||||
#noise=' '.join(args['<noise>']).strip().lower()
|
|
||||||
url=self.url
|
url=self.url
|
||||||
#pdb.set_trace()
|
|
||||||
if noise.split()[0]=="list":
|
if noise.split()[0]=="list":
|
||||||
# LIST
|
# LIST
|
||||||
self.models=[]
|
self.models=[]
|
||||||
@ -107,12 +144,10 @@ class Plugin:
|
|||||||
self.bot.privmsg(target,MODEL)
|
self.bot.privmsg(target,MODEL)
|
||||||
|
|
||||||
if noise.split()[0]=="set":
|
if noise.split()[0]=="set":
|
||||||
#import pdb
|
|
||||||
# SET
|
# SET
|
||||||
PARAMS=[' model', 'prompt','negative_prompt','prompt+','negative_prompt+','steps','cfg_scale','seed','width','height','restore_faces']
|
PARAMS=[' model', 'prompt','negative_prompt','prompt+','negative_prompt+','steps','cfg_scale','seed','width','height','restore_faces']
|
||||||
TARAMS=[ [str,int], [str], [str], [str], [str], [int], [float], [int], [int], [int], [bool]]
|
TARAMS=[ [str,int], [str], [str], [str], [str], [int], [float], [int], [int], [int], [bool]]
|
||||||
try:
|
try:
|
||||||
#pdb.set_trace()
|
|
||||||
PARAM=args.get('<param>')
|
PARAM=args.get('<param>')
|
||||||
try:
|
try:
|
||||||
assert PARAM in PARAMS
|
assert PARAM in PARAMS
|
||||||
@ -261,4 +296,5 @@ class Plugin:
|
|||||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< error {GREY}>>>"))
|
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< error {GREY}>>>"))
|
||||||
self.running=False
|
self.running=False
|
||||||
|
|
||||||
############################################################################################################ EOF
|
###########################################################################################
|
||||||
|
####################################################################################### EOF
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import requests
|
import requests
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def ud(self, mask, target, args):
|
def ud(self, mask, target, args):
|
||||||
"""Urban Dictonary A Term
|
"""Urban Dictonary A Term
|
||||||
@ -28,7 +36,9 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
msg = "{} Term Not Found".format(term)
|
msg = "{} Term Not Found".format(term)
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
???TWITTER???
|
???TWITTER???
|
||||||
???YOUTUBE???
|
???YOUTUBE???
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
import re
|
import re
|
||||||
@ -10,24 +14,40 @@ import requests
|
|||||||
from lxml.html import fromstring
|
from lxml.html import fromstring
|
||||||
TOO_LONG = 2000
|
TOO_LONG = 2000
|
||||||
URL_REGEX = re.compile('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', re.IGNORECASE)
|
URL_REGEX = re.compile('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', re.IGNORECASE)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_TWITTER:
|
if SERVICES_TWITTER:
|
||||||
|
####################
|
||||||
|
|
||||||
TWITTER_REGEX = re.compile('https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$', re.IGNORECASE)
|
TWITTER_REGEX = re.compile('https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$', re.IGNORECASE)
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg(self, mask=None, target=None, data=None, **kw):
|
||||||
if not data.find('reacted with :') == -1: return
|
if not data.find('reacted with :') == -1: return
|
||||||
@ -35,25 +55,39 @@ class Plugin:
|
|||||||
if self.bot.check_if_ignored(mask): return
|
if self.bot.check_if_ignored(mask): return
|
||||||
if mask.nick == '[0]' or mask.nick == '[0]_': return
|
if mask.nick == '[0]' or mask.nick == '[0]_': return
|
||||||
self.__check_for_url(data,target,mask)
|
self.__check_for_url(data,target,mask)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __check_for_url(self,msg,target,mask):
|
def __check_for_url(self,msg,target,mask):
|
||||||
match_list = URL_REGEX.findall(msg)
|
match_list = URL_REGEX.findall(msg)
|
||||||
read_size = 0
|
read_size = 0
|
||||||
if match_list:
|
if match_list:
|
||||||
url = match_list.pop()
|
url = match_list.pop()
|
||||||
|
|
||||||
|
##########################################
|
||||||
if not url.lower().find('wp-login') == -1:
|
if not url.lower().find('wp-login') == -1:
|
||||||
|
##########################################
|
||||||
|
|
||||||
msg = 'pre-fetch aborted -> hell nah nigga'
|
msg = 'pre-fetch aborted -> hell nah nigga'
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_YOUTUBE:
|
if SERVICES_YOUTUBE:
|
||||||
|
####################
|
||||||
|
|
||||||
y_match = YOUTUBE_REGEX.findall(url)
|
y_match = YOUTUBE_REGEX.findall(url)
|
||||||
if y_match:
|
if y_match:
|
||||||
y_match = y_match.pop()
|
y_match = y_match.pop()
|
||||||
if len(y_match) == 3:
|
if len(y_match) == 3:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
####################
|
||||||
if SERVICES_TWITTER:
|
if SERVICES_TWITTER:
|
||||||
|
####################
|
||||||
|
|
||||||
t_match = TWITTER_REGEX.findall(url)
|
t_match = TWITTER_REGEX.findall(url)
|
||||||
if t_match:
|
if t_match:
|
||||||
t_match = t_match.pop()
|
t_match = t_match.pop()
|
||||||
@ -90,9 +124,15 @@ class Plugin:
|
|||||||
msg = "\x02\x0302{nick:}\x0F\x02\x0304 > \x0F\x1D\x0314{title:}\x0F".format(nick=mask.nick,title=title)
|
msg = "\x02\x0302{nick:}\x0F\x02\x0304 > \x0F\x1D\x0314{title:}\x0F".format(nick=mask.nick,title=title)
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
######## URL_GRABBER <-> BOOMBOX_PLUGIN HOOK ######## URL_GRABBER <-> BOOMBOX_PLUGIN HOOK ########
|
|
||||||
|
########### URL_GRABBER <-> BOOMBOX_PLUGIN HOOK <-> URL_GRABBER
|
||||||
|
########### URL_GRABBER <-> BOOMBOX_PLUGIN HOOK <-> URL_GRABBER
|
||||||
|
|
||||||
self.bot.bbs.enter(mask.nick,url,title)
|
self.bot.bbs.enter(mask.nick,url,title)
|
||||||
######## URL_GRABBER <-> BOOMBOX_PLUGIN HOOK ######## URL_GRABBER <-> BOOMBOX_PLUGIN HOOK ########
|
|
||||||
|
########### URL_GRABBER <-> BOOMBOX_PLUGIN HOOK <-> URL_GRABBER
|
||||||
|
########### URL_GRABBER <-> BOOMBOX_PLUGIN HOOK <-> URL_GRABBER
|
||||||
|
|
||||||
return
|
return
|
||||||
read_size = read_size + 2000
|
read_size = read_size + 2000
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -100,6 +140,7 @@ class Plugin:
|
|||||||
pass
|
pass
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def prefetch_title(self,msg,target,mask):
|
def prefetch_title(self,msg,target,mask):
|
||||||
match_list = URL_REGEX.findall(msg)
|
match_list = URL_REGEX.findall(msg)
|
||||||
@ -128,6 +169,6 @@ class Plugin:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("%s" % e)
|
print("%s" % e)
|
||||||
pass
|
pass
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF#.[d].
|
####################################################################################### EOF
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
import irc3
|
import irc3
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
@irc3.plugin
|
@irc3.plugin
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def whoami(self, mask, target, args):
|
def whoami(self, mask, target, args):
|
||||||
"""whoami - plugin to give some identity information. usage: ?whoami
|
"""whoami - plugin to give some identity information. usage: ?whoami
|
||||||
@ -15,6 +26,6 @@ class Plugin:
|
|||||||
"""
|
"""
|
||||||
msg = f'{mask.nick}: mask: {mask} channel: {target}'
|
msg = f'{mask.nick}: mask: {mask} channel: {target}'
|
||||||
self.bot.privmsg(target, self.bot.emo(msg))
|
self.bot.privmsg(target, self.bot.emo(msg))
|
||||||
#######################################################################################
|
|
||||||
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -1,38 +1,81 @@
|
|||||||
# -*- coding: utf-8 -*- ############################################################### SOF
|
# -*- coding: utf-8 -*- ############################################################### SOF
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
???YOUTUBE???
|
???YOUTUBE???
|
||||||
from irc3.plugins.command import command
|
|
||||||
import irc3
|
###########################################################################################
|
||||||
import os
|
###########################################################################################
|
||||||
import re
|
|
||||||
import datetime
|
####################
|
||||||
import dateutil.parser
|
if SERVICES_YOUTUBE:
|
||||||
import timeago
|
####################
|
||||||
import isodate
|
|
||||||
from apiclient.discovery import build
|
from irc3.plugins.command import command
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
import irc3
|
||||||
try:
|
import os
|
||||||
if SERVICES_YOUTUBE:
|
import re
|
||||||
YOUTUBE_DEVELOPER_KEY = os.environ['YOUTUBE_DEVELOPER_KEY']
|
import sys
|
||||||
|
import datetime
|
||||||
|
import dateutil.parser
|
||||||
|
import timeago
|
||||||
|
import isodate
|
||||||
|
from apiclient.discovery import build
|
||||||
|
from plugins.tool_log_plugin import FOG
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
def getenv(s):
|
||||||
|
try:
|
||||||
|
s = os.environ[s]
|
||||||
|
return s
|
||||||
|
except:
|
||||||
|
fog=FOG().fog
|
||||||
|
error_type="environmental variable error"
|
||||||
|
error_reason=f"exported {s} not found"
|
||||||
|
fog(f"{error_type}: {error_reason}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
YOUTUBE_DEVELOPER_KEY = getenv('YOUTUBE_DEVELOPER_KEY')
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
YOUTUBE_API_SERVICE_NAME = "youtube"
|
YOUTUBE_API_SERVICE_NAME = "youtube"
|
||||||
YOUTUBE_API_VERSION = "v3"
|
YOUTUBE_API_VERSION = "v3"
|
||||||
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
|
||||||
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=YOUTUBE_DEVELOPER_KEY)
|
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=YOUTUBE_DEVELOPER_KEY)
|
||||||
except:
|
|
||||||
pass
|
|
||||||
###########################################################################################
|
|
||||||
###########################################################################################
|
|
||||||
@irc3.plugin
|
|
||||||
class Plugin:
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
||||||
|
|
||||||
|
#######################################################################################
|
||||||
|
#######################################################################################
|
||||||
|
|
||||||
|
@irc3.plugin
|
||||||
|
class Plugin:
|
||||||
|
|
||||||
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.bot.channel_live = []
|
self.bot.channel_live = []
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def youtube_search(self, q=None, eventType=None, max_results=1, order="relevance", channelId=None, token=None, location=None, location_radius=None):
|
def youtube_search(self, q=None, eventType=None, max_results=1, order="relevance", channelId=None, token=None, location=None, location_radius=None):
|
||||||
if SERVICES_YOUTUBE:
|
|
||||||
search_response = youtube.search().list(
|
search_response = youtube.search().list(
|
||||||
q=q,
|
q=q,
|
||||||
channelId=channelId,
|
channelId=channelId,
|
||||||
@ -48,18 +91,20 @@ class Plugin:
|
|||||||
for search_result in search_response.get("items", []):
|
for search_result in search_response.get("items", []):
|
||||||
if search_result["id"]["kind"] == "youtube#video":
|
if search_result["id"]["kind"] == "youtube#video":
|
||||||
return(search_result)
|
return(search_result)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
@irc3.event(irc3.rfc.PRIVMSG)
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||||||
def on_privmsg_search_for_youtube(self, mask=None, target=None, data=None, **kw):
|
def on_privmsg_search_for_youtube(self, mask=None, target=None, data=None, **kw):
|
||||||
if SERVICES_YOUTUBE:
|
|
||||||
if data.startswith("?"): return
|
if data.startswith("?"): return
|
||||||
if self.bot.check_if_ignored(mask): return
|
if self.bot.check_if_ignored(mask): return
|
||||||
self.__check_for_youtube(mask, data, target)
|
self.__check_for_youtube(mask, data, target)
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
def __check_for_youtube(self, mask, msg, target):
|
def __check_for_youtube(self, mask, msg, target):
|
||||||
if SERVICES_YOUTUBE:
|
|
||||||
match_list = YOUTUBE_REGEX.findall(msg)
|
match_list = YOUTUBE_REGEX.findall(msg)
|
||||||
if match_list:
|
if match_list:
|
||||||
video_id = match_list.pop()
|
video_id = match_list.pop()
|
||||||
@ -81,7 +126,10 @@ class Plugin:
|
|||||||
topics[:] = [i.replace("https://en.wikipedia.org/wiki/", "").replace("_"," ").title() for i in topics]
|
topics[:] = [i.replace("https://en.wikipedia.org/wiki/", "").replace("_"," ").title() for i in topics]
|
||||||
except:
|
except:
|
||||||
topics = []
|
topics = []
|
||||||
######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 ######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 ########
|
|
||||||
|
################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 <-> YOUTUBE
|
||||||
|
################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 <-> YOUTUBE
|
||||||
|
|
||||||
MUSIC_FOUND=False
|
MUSIC_FOUND=False
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
if topic.lower().find('music'):
|
if topic.lower().find('music'):
|
||||||
@ -89,7 +137,10 @@ class Plugin:
|
|||||||
if MUSIC_FOUND:
|
if MUSIC_FOUND:
|
||||||
url = "https://youtu.be/{}".format(video_id)
|
url = "https://youtu.be/{}".format(video_id)
|
||||||
self.bot.bbs.enter(mask.nick,url,title)
|
self.bot.bbs.enter(mask.nick,url,title)
|
||||||
######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 ######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 ########
|
|
||||||
|
################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 <-> YOUTUBE
|
||||||
|
################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 1 of 2 <-> YOUTUBE
|
||||||
|
|
||||||
duration = isodate.parse_duration(video_info.get("contentDetails").get("duration"))
|
duration = isodate.parse_duration(video_info.get("contentDetails").get("duration"))
|
||||||
msg = "\x02\x0302{nick:}\x0F\x02\x0304 >> \x02\x0303\x1D\x1F{title:}\x0F".format(nick=mask.nick, title=title)
|
msg = "\x02\x0302{nick:}\x0F\x02\x0304 >> \x02\x0303\x1D\x1F{title:}\x0F".format(nick=mask.nick, title=title)
|
||||||
msg = msg + "\x02\x1D\x0304 > \x0F\x1D\x0314Duration: \x0F\x1D{duration:} \x0F".format(duration=duration)
|
msg = msg + "\x02\x1D\x0304 > \x0F\x1D\x0314Duration: \x0F\x1D{duration:} \x0F".format(duration=duration)
|
||||||
@ -101,33 +152,36 @@ class Plugin:
|
|||||||
msg = msg +" \x0304> \x0F\x02\x0312"+ url
|
msg = msg +" \x0304> \x0F\x02\x0312"+ url
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target,msg)
|
self.bot.privmsg(target,msg)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
def videos_list_by_id(self, id):
|
def videos_list_by_id(self, id):
|
||||||
if SERVICES_YOUTUBE:
|
|
||||||
search_response = youtube.videos().list(part="id,snippet,statistics,topicDetails,contentDetails", id=id).execute()
|
search_response = youtube.videos().list(part="id,snippet,statistics,topicDetails,contentDetails", id=id).execute()
|
||||||
for search_result in search_response.get("items", []):
|
for search_result in search_response.get("items", []):
|
||||||
if search_result["kind"] == "youtube#video":
|
if search_result["kind"] == "youtube#video":
|
||||||
return(search_result)
|
return(search_result)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
@command(permission='view', public=True, show_in_help_list=False)
|
@command(permission='view', public=True, show_in_help_list=False)
|
||||||
def y(self, *args, **kwargs):
|
def y(self, *args, **kwargs):
|
||||||
"""Search for youtube video
|
"""Search for youtube video
|
||||||
%%y <keyword>...
|
%%y <keyword>...
|
||||||
"""
|
"""
|
||||||
if SERVICES_YOUTUBE:
|
|
||||||
return self.yt(*args)
|
return self.yt(*args)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###################################################################################
|
||||||
|
###################################################################################
|
||||||
|
|
||||||
@irc3.extend
|
@irc3.extend
|
||||||
@command(permission='view')
|
@command(permission='view')
|
||||||
def yt(self, mask, target, args):
|
def yt(self, mask, target, args):
|
||||||
"""Search for youtube video
|
"""Search for youtube video
|
||||||
%%yt <keyword>...
|
%%yt <keyword>...
|
||||||
"""
|
"""
|
||||||
if SERVICES_YOUTUBE:
|
|
||||||
keyword = ' '.join(args['<keyword>'])
|
keyword = ' '.join(args['<keyword>'])
|
||||||
video = self.youtube_search(q=keyword)
|
video = self.youtube_search(q=keyword)
|
||||||
if video:
|
if video:
|
||||||
@ -150,7 +204,10 @@ class Plugin:
|
|||||||
except:
|
except:
|
||||||
topics = []
|
topics = []
|
||||||
duration = isodate.parse_duration(video_info.get("contentDetails").get("duration"))
|
duration = isodate.parse_duration(video_info.get("contentDetails").get("duration"))
|
||||||
######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 ######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 ########
|
|
||||||
|
####################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 <-> YOUTUBE
|
||||||
|
####################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 <-> YOUTUBE
|
||||||
|
|
||||||
MUSIC_FOUND=False
|
MUSIC_FOUND=False
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
if topic.lower().find('music'):
|
if topic.lower().find('music'):
|
||||||
@ -158,7 +215,10 @@ class Plugin:
|
|||||||
if MUSIC_FOUND:
|
if MUSIC_FOUND:
|
||||||
url = "https://youtu.be/{}".format(video_id)
|
url = "https://youtu.be/{}".format(video_id)
|
||||||
self.bot.bbs.enter(mask.nick,url,title)
|
self.bot.bbs.enter(mask.nick,url,title)
|
||||||
######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 ######## YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 ########
|
|
||||||
|
####################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 <-> YOUTUBE
|
||||||
|
####################### YOUTUBE <-> BOOMBOX_PLUGIN HOOK: 2 of 2 <-> YOUTUBE
|
||||||
|
|
||||||
_nick = ""
|
_nick = ""
|
||||||
try:
|
try:
|
||||||
if len(self.bot.madjust) > 0:
|
if len(self.bot.madjust) > 0:
|
||||||
@ -177,7 +237,6 @@ class Plugin:
|
|||||||
msg = msg + url
|
msg = msg + url
|
||||||
msg = self.bot.emo(msg)
|
msg = self.bot.emo(msg)
|
||||||
self.bot.privmsg(target, msg)
|
self.bot.privmsg(target, msg)
|
||||||
#######################################################################################
|
|
||||||
#######################################################################################
|
###########################################################################################
|
||||||
####################################################################################### EOF
|
####################################################################################### EOF
|
||||||
#.[d].
|
|
||||||
|
@ -2,3 +2,4 @@ irc3
|
|||||||
aiocron
|
aiocron
|
||||||
timeago
|
timeago
|
||||||
ipdb
|
ipdb
|
||||||
|
sqlite3
|
@ -8,3 +8,4 @@ lxml
|
|||||||
aiocron
|
aiocron
|
||||||
ipdb
|
ipdb
|
||||||
pytz
|
pytz
|
||||||
|
sqlite3
|
@ -23,3 +23,5 @@ transformers==2.3.0
|
|||||||
googletrans==2.4.0
|
googletrans==2.4.0
|
||||||
textblob==0.15.3
|
textblob==0.15.3
|
||||||
matplotlib
|
matplotlib
|
||||||
|
sqlite3
|
||||||
|
sklearn
|
Loading…
Reference in New Issue
Block a user