This commit is contained in:
.[d]. 2023-03-15 14:05:43 -05:00
parent 797a912adb
commit a32c7649fa
11 changed files with 1387 additions and 1189 deletions

108
maple

@ -41,24 +41,14 @@
# echo -e '\033[0;34m'"/MMMMMMm. -hMMMMMN: /NMMMM. dMMMMMMMMMMMMMh- :hmNy. .NMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMm- -yNMMMm. .yMMM. dMMMMMMMMMMMMMMNh:. .... yMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMN+ .+hNMd. :hM: dMMMMMMMMMMMMMMMMNmo- .NMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMh- ./ss. .:: sMMMMMMMMMMMMMMMMMMMNms/. /MMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMNo. . :MMMMMMMMMMMMMMMMMMMMMMMNdo:.. oMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMmo. .mMMMMMMMMMMMMMMMMMMMMMMMMMMNmh: .dMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMNy:. +MMMMMMMMMMMMMMMMMMMMMMMMMMNh+::/+sdNMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMNdo- .dMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMNd+-. -NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"-NMMMMMMMMMMMMMMMMMMMMMMNdo:. /NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd."
# echo -e '\033[0;34m'" -ymNNNNNNNNNNNNNNNNNNNNNNNNdo-. +NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmy."
# echo -e '\033[0;34m'" ............................ .-................................"
# echo -e '\033[0;34m'" ...... ......... .............. .......... saiset ......\n"
#####################################################################################################################
# echo -e '\033[0;34m'"/MMMMMMM
i=`cat maple|grep -n MARKER|cut -f1 -d":"`;i=$(echo $i|xargs|cut -f2 -d" ");ii=`wc -l maple|cut -f1 -d" "`;
iii=$((ii-i));tail -n $iii $0>mpl;MD5=$(md5sum mpl|cut -f1 -d ' ');rm mpl;DM5="5bf899243b45e9609fcb4386087692fd";
iii=$((ii-i));tail -n $iii $0>mpl;MD5=$(md5sum mpl|cut -f1 -d ' ');rm mpl;DM5="53ecf9877ffa225517aa34e52dab232c";
[ "$MD5" = "$DM5" ] || exit;
# MARKER ############################################################################################################
#####################################################################################################################
R="\x1b[5;31m";G="\x1b[5;32m";Y="\x1b[5;33m";B="\x1b[5;34m";M="\x1b[5;35m";C="\x1b[5;36m";W="\x1b[5;37m";
CMD=$1;
@ -69,6 +59,8 @@ DISCORD__SERVICING=-1
TELEGRAM_SERVICING=-1
MATRIX___SERVICING=-1
OPENAI___SERVICING=-1
HYDRA____SERVICING=-1
CRYPTO___SERVICING=-1
YOUTUBE__SERVICING=-1
TWITTER__SERVICING=-1
@ -108,6 +100,7 @@ if [ -e preset ]; then
fi
fi
#####################################################################################################################
#####################################################################################################################
function rgb () {
@ -117,6 +110,7 @@ function rgb () {
echo -e "\e[38;2;"$R";"$G";"$B"m"
}
#####################################################################################################################
#####################################################################################################################
function analyze () {
@ -138,6 +132,7 @@ function analyze () {
echo -e "EOF #########################################################"
}
#####################################################################################################################
#####################################################################################################################
function pin_ops () {
@ -268,6 +263,7 @@ function pin_ops () {
}
#####################################################################################################################
#####################################################################################################################
kset() {
@ -275,6 +271,7 @@ kset() {
echo "$1 = $2" >> $CONFIG
}
#####################################################################################################################
#####################################################################################################################
kwrite() {
@ -282,12 +279,14 @@ kwrite() {
echo "$1" >> $CONFIG
}
#####################################################################################################################
#####################################################################################################################
kblank() {
echo "" >> $CONFIG
}
#####################################################################################################################
#####################################################################################################################
kmodesetup() {
@ -321,7 +320,6 @@ kmodesetup() {
[ "$MODE" = "2" ] && (cp storage/bot/variants/dupe/bot_maple__services.py bot_maple.py;pip install -r storage/bot/requirements/requirements_services.txt)
[ "$MODE" = "3" ] && (cp storage/bot/variants/dupe/bot_maple__devops.py bot_maple.py;pip install -r storage/bot/requirements/requirements_devops.txt)
echo -e "\n[ $HYDRA setup complete ]"
deactivate
echo -e "[ setting up $HYDRA activation ]"
@ -350,6 +348,7 @@ kmodesetup() {
#############################################################################################################
}
#####################################################################################################################
#####################################################################################################################
kmode () {
@ -369,6 +368,7 @@ kmode () {
kmodesetup "$HYDRA" "$MODE"
}
#####################################################################################################################
#####################################################################################################################
kprompt() {
@ -459,6 +459,8 @@ kprompt() {
return 0;
}
#####################################################################################################################
#####################################################################################################################
cmd_hydra_dak () {
@ -558,6 +560,7 @@ cmd_hydra_dak () {
fi
}
#####################################################################################################################
#####################################################################################################################
cmd_hydra_undak () {
@ -615,6 +618,7 @@ cmd_hydra_undak () {
rm dr1p_*; rm dak_*; rm undak.py; rm unkey.py;
}
#####################################################################################################################
#####################################################################################################################
cmd_hydra () {
@ -637,15 +641,19 @@ cmd_hydra () {
cmd_hydra_dak;
fi;
}
#####################################################################################################################
#####################################################################################################################
cmd_default () {
(kmode 0);
}
#####################################################################################################################
#####################################################################################################################
cmd_services_hydra () {
HYDRA____SERVICING=1
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
echo -e "\n"$G"[ "$L"setting up services "$G"]\n"
[ -e storage/user/credentials ] || (mkdir -p storage/user/credentials)
@ -735,7 +743,7 @@ cmd_services_hydra () {
else
DISCORD__SERVICING=0
fi
kprompt "MODE" "will this bot use telegram services? " "discord" 1 0 0; RESULT=$?
kprompt "MODE" "will this bot use telegram services? " "telegram" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "telegram_token" "[ telegram token ] example: 5405833579:AAHvEUc1hms29JBoJDhoGBUE8Ept8dBrZr5" 1 3 0; RESULT=$?
echo -e "export TELEGRAM_TOKEN=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
@ -743,11 +751,18 @@ cmd_services_hydra () {
else
TELEGRAM_SERVICING=0
fi
# [ -e storage/user/credentials/activate__hydra_dupe__services ] && ( cat storage/user/credentials/activate__hydra_dupe__services >> env/bin/activate )
kprompt "MODE" "will this bot use cryptocompare services? " "cryptocompare" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "cryptocompare_token" "[ cryptocompare token ] example: 8wXfZYl4cN4iSmKsRVOhXDCVxF9wZ8c7Qy4o4bKgTVpcplq9Q8oId0mY" 1 3 0; RESULT=$?
echo -e "export CRYPTOCOMPARE_TOKEN=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
CRYPTO___SERVICING=1
else
CRYPTO___SERVICING=0
fi
}
#####################################################################################################################
#####################################################################################################################
cmd_services () {
@ -804,10 +819,9 @@ cmd_services () {
echo -e "export TELEGRAM_TOKEN=$REPLY" >> activation
fi
# [ -e storage/user/credentials/activate__hydra_dupe__services ] && ( cat storage/user/credentials/activate__hydra_dupe__services >> env/bin/activate )
}
#####################################################################################################################
#####################################################################################################################
cmd_setup () {
@ -822,7 +836,6 @@ cmd_setup () {
mkdir plugins
cat storage/bot/variants/default/bot_maple__default__initial_plugins.txt|grep -v "#"|grep -v irc3|sed s/plugins.//|xargs -I{} cp storage/bot/plugins/{}.py plugins/
# ideally i would simply use sed -i s/this/that/g file; however osx/unix and gnused are not exactly posix compliant(idc) specifically with (inplace) file updating, ppl getting gsed on osx vs using ased, ill skip past.
if [ $DISCORD__SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
@ -863,8 +876,10 @@ cmd_setup () {
if [ $TWITTER__SERVICING -eq 0 ]; then
cat plugins/url_grabber_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=False"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
cat plugins/twitter_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
else
cat plugins/url_grabber_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=True"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
cat plugins/twitter_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
fi
if [ $YOUTUBE__SERVICING -eq 0 ]; then
@ -879,6 +894,23 @@ cmd_setup () {
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
fi
if [ $HYDRA____SERVICING -eq 0 ]; then
cat plugins/net_hydra_plugin.py|sed s/"???HYDRA???"/"SERVICES_HYDRA=False"/g > plugins/net_hydra_plugin.tmp;mv plugins/net_hydra_plugin.tmp plugins/net_hydra_plugin.py
else
cat plugins/net_hydra_plugin.py|sed s/"???HYDRA???"/"SERVICES_HYDRA=True"/g > plugins/net_hydra_plugin.tmp;mv plugins/net_hydra_plugin.tmp plugins/net_hydra_plugin.py
fi
if [ $OPENAI___SERVICING -eq 0 ]; then
cat plugins/openai_plugin.py|sed s/"???OPENAI???"/"SERVICES_OPENAI=False"/g > plugins/openai_plugin.tmp;mv plugins/openai_plugin.tmp plugins/openai_plugin.py
else
cat plugins/openai_plugin.py|sed s/"???OPENAI???"/"SERVICES_OPENAI=True"/g > plugins/openai_plugin.tmp;mv plugins/openai_plugin.tmp plugins/openai_plugin.py
fi
if [ $CRYPTO___SERVICING -eq 0 ]; then
cat plugins/crypto_plugin.py|sed s/"???CRYPTOCOMPARE???"/"SERVICES_CRYPTOCOMPARE=False"/g > plugins/crypto_plugin.tmp;mv plugins/crypto_plugin.tmp plugins/crypto_plugin.py
else
cat plugins/crypto_plugin.py|sed s/"???CRYPTOCOMPARE???"/"SERVICES_CRYPTOCOMPARE=True"/g > plugins/crypto_plugin.tmp;mv plugins/crypto_plugin.tmp plugins/crypto_plugin.py
fi
if [ $DISCORD__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
@ -898,21 +930,17 @@ cmd_setup () {
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
fi;
fi;
if [ $RESULT -eq 2 ]; then
#kprompt "MODE" "$L""\nalready have an online credential pak? " "credential pak" 1 0 0; RESULT=$?
#echo $RESULT
#if [ $RESULT = "0" ]; then
cmd_services_hydra
[ -e storage/user/config/hydra.key ] || cmd_hydra;
#fi;
cmd_setup_bot
fi;
fi;
}
#####################################################################################################################
#####################################################################################################################
cmd_setup_bot () {
@ -1023,6 +1051,7 @@ cmd_setup_bot () {
}
#####################################################################################################################
#####################################################################################################################
cmd_start () {
@ -1057,14 +1086,16 @@ cmd_start () {
}; # eof cmd_start
################
#####################################################################################################################
#####################################################################################################################
cmd_stop () {
echo -e "[ stopping `cat r3kt.pid` ]"
pid=`cat r3kt.pid` && kill -9 $pid;rm r3kt.pid
}
################
#####################################################################################################################
#####################################################################################################################
cmd_cleanup () {
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
@ -1093,7 +1124,9 @@ cmd_cleanup () {
[ -e r3kt.pid ] && (PID=`cat r3kt.pid`;rm r3kt.pid;kill -9 $PID > /dev/null 2>&1)
}
################
#####################################################################################################################
#####################################################################################################################
cmd_autosync () {
########################################################################################################################## SOF
@ -1122,6 +1155,7 @@ cmd_autosync () {
########################################################################################################################## EOF
}
#####################################################################################################################
#####################################################################################################################
error () {
@ -1129,11 +1163,14 @@ error () {
}
#####################################################################################################################
#####################################################################################################################
help () {
[ $1 -eq 1 ] && echo -e $W"commands: ${COMMANDS[*]}"
}
#####################################################################################################################
#####################################################################################################################
#####################################################################################################################
@ -1142,11 +1179,10 @@ help () {
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
#####################################################################################################################
#####################################################################################################################
#####################################################################################################################
#[ -z $1 ] && error "no command issued" && help 1 && exit
if [ -z $1 ]; then
# detect bot setup, if none start setup
if [ ! -e bot_maple.ini ] || [ ! -e bot_maple.py ]; then
cmd_setup;
@ -1175,7 +1211,7 @@ if [ -z $1 ]; then
fi
fi
# detect bot pid, if no pid then start bot, if pid then stop bot
if [ ! -e r3kt.pid ]; then
cmd_start;
elif [ -e r3kt.pid ]; then
@ -1184,9 +1220,7 @@ if [ -z $1 ]; then
fi;
#####################################################################################################################
# if grep -q "$CMD" <<< "${commands[@]}"; then
# echo -e "$CMD command found"
#####################################################################################################################
if [ "$CMD" = "setup" ]; then
cmd_setup;
@ -1200,10 +1234,7 @@ fi;
cmd_autosync;
fi;
# else
# error "$1 isn't an available command" && help 1 && exit 1
# fi
#####################################################################################################################
#####################################################################################################################
#####################################################################################################################
@ -1213,5 +1244,4 @@ fi;
#####################################################################################################################
#####################################################################################################################
################################################################################################################# EOF

@ -1,15 +1,24 @@
# -*- coding: utf-8 -*- ############################################################### SOF
###########################################################################################
import sys
from irc3.plugins.command import command
import irc3,os,aiohttp, asyncio, async_timeout
from plugins.tool_log_plugin import FOG
???CRYPTOCOMPARE???
###########################################################################################
###########################################################################################
def getenv(s):
##########################
if SERVICES_CRYPTOCOMPARE:
##########################
import sys
from irc3.plugins.command import command
import irc3,os,aiohttp, asyncio, async_timeout
from plugins.tool_log_plugin import FOG
#######################################################################################
#######################################################################################
def getenv(s):
try:
s = os.environ[s]
return s
@ -20,26 +29,26 @@ def getenv(s):
fog(f"{error_type}: {error_reason}")
sys.exit(1)
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
CRYPTOCOMPARE_KEY=getenv('CRYPTOCOMPARE_KEY')
CRYPTOCOMPARE_KEY=getenv('CRYPTOCOMPARE_KEY')
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
headers = { 'authorization': f'Apikey {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__))
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
@irc3.plugin
class Plugin:
@irc3.plugin
class Plugin:
#######################################################################################
#######################################################################################
@ -61,16 +70,16 @@ class Plugin:
async with session.get(url) as response:
return await response.json()
###################################################################################
###################################################################################
###############################################################################
###############################################################################
async def grab_url(url):
async with aiohttp.ClientSession(headers=headers) as session:
json_response = await fetch(session, url)
return json_response
###################################################################################
###################################################################################
###############################################################################
###############################################################################
def parse_coin(response):
try:
@ -114,8 +123,8 @@ class Plugin:
msg = self.bot.emo('their api is glitching: check back later')
self.bot.privmsg(target, msg)
###################################################################################
###################################################################################
###############################################################################
###############################################################################
def process_lookups(response):
try:
@ -138,8 +147,8 @@ class Plugin:
task = self.bot.create_task(asyncio.wait(tasks))
task.add_done_callback(parse_coin)
###################################################################################
###################################################################################
###############################################################################
###############################################################################
url = "https://min-api.cryptocompare.com/data/all/coinlist"
asyncio.ensure_future(grab_url(url), \

@ -1,20 +1,29 @@
# -*- coding: utf-8 -*- ############################################################### SOF
###########################################################################################
from irc3.plugins.command import command
from irc3.plugins.cron import cron
from irc3.plugins import core
import irc3
import os
from random import randint as rint
from random import shuffle
from datetime import datetime
import socket
???HYDRA???
###########################################################################################
###########################################################################################
class dr1p:
##################
if SERVICES_HYDRA:
##################
from irc3.plugins.command import command
from irc3.plugins.cron import cron
from irc3.plugins import core
import irc3
import os
from random import randint as rint
from random import shuffle
from datetime import datetime
import socket
#######################################################################################
#######################################################################################
class dr1p:
def __init__():
dr1p.designation=""
dr1p.enforcing=False
@ -23,11 +32,11 @@ class dr1p:
dr1p.keyid=""
dr1p.home=""
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
@irc3.plugin
class Plugin:
@irc3.plugin
class Plugin:
def generate_keyid_token(self,mode=1):
if mode:
token=""
@ -46,8 +55,8 @@ class Plugin:
keyid=''.join(keyid)
return keyid
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def __init__(self,bot):
self.bot=bot
@ -66,8 +75,8 @@ class Plugin:
dr1p.keyid=self.generate_keyid_token(0)
dr1p.token=self.generate_keyid_token(1)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def server_ready(self):
if not dr1p.designation=='core':
@ -78,8 +87,8 @@ class Plugin:
dr1p.token=self.generate_keyid_token(1)
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - purpose: {dr1p.purpose} - core - connected")
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.ERR_NICK)
def on_errnick(self,srv=None,retcode=None,me=None,nick=None,data=None):
@ -87,8 +96,8 @@ class Plugin:
msg=f'err_nick - srv:{srv} - retcode:{retcode} - me:{me} - nick:{nick} - data:{data}'
self.bot.privmsg("maple",msg.lower())
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.NEW_NICK)
def on_newnick(self,nick=None,new_nick=None):
@ -97,8 +106,8 @@ class Plugin:
msg=f'new_nick - nick:{nick} - new_nick:{new_nick}'
self.bot.privmsg("maple",msg.lower())
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.CTCP)
def on_ctcp(self,mask=None,event=None,target=None,ctcp=None):
@ -106,8 +115,8 @@ class Plugin:
msg=f'ctcpd - mask:{mask} - event:{event} - target:{target} - ctcp:{ctcp}'
self.bot.privmsg("maple",msg.lower())
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.INVITE)
def on_invite(self,mask=None,channel=None):
@ -115,16 +124,16 @@ class Plugin:
msg=f'invited - mask:{mask} - channel:{channel}'
self.bot.privmsg("maple",msg.lower())
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.KICK)
def on_kick(self,mask=None,event=None,channel=None,target=None,data=None):
msg=f'kicked - mask:{mask} - event:{event} - target:{target} - data:{data}'
self.bot.privmsg(dr1p.home,msg)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.PRIVMSG)
def on_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
@ -177,15 +186,15 @@ class Plugin:
except:
self.bot.privmsg(dr1p.home,"exception - "+msg.lower())
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.MY_PRIVMSG)
def on_my_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
pass
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):

@ -1,29 +1,38 @@
# -*- coding: utf-8 -*- ############################################################### SOF
###########################################################################################
import os
import re
import sys
from difflib import SequenceMatcher
import urllib.parse
import irc3
import openai
import requests
from irc3.plugins.command import command
from random import randint as rint
from random import choices
from glob import glob
from plugins.tool_log_plugin import FOG
???OPENAI???
###########################################################################################
###########################################################################################
dir_path = os.path.dirname(os.path.realpath(__file__))
###################
if SERVICES_OPENAI:
###################
###########################################################################################
###########################################################################################
import os
import re
import sys
from difflib import SequenceMatcher
import urllib.parse
import irc3
import openai
import requests
from irc3.plugins.command import command
from random import randint as rint
from random import choices
from glob import glob
from plugins.tool_log_plugin import FOG
def getenv(s):
#######################################################################################
#######################################################################################
dir_path = os.path.dirname(os.path.realpath(__file__))
#######################################################################################
#######################################################################################
def getenv(s):
try:
s = os.environ[s]
return s
@ -34,62 +43,62 @@ def getenv(s):
fog(f"{error_type}: {error_reason}")
sys.exit(1)
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
OPENAI_KEY = getenv('OPENAI_KEY')
###########################################################################################
###########################################################################################
DREY="\x02\x0315"
GREY="\x02\x0314"
DRED="\x02\x0302"
LRED="\x02\x0312"
###########################################################################################
###########################################################################################
class OPENAI_MESSAGE_HISTORY():
OPENAI_KEY = getenv('OPENAI_KEY')
#######################################################################################
#######################################################################################
DREY="\x02\x0315"
GREY="\x02\x0314"
DRED="\x02\x0302"
LRED="\x02\x0312"
#######################################################################################
#######################################################################################
class OPENAI_MESSAGE_HISTORY():
###################################################################################
###################################################################################
openai_messages = []
user_messages = []
user_users = []
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def __init__(self):
self.processing=0
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def push_openai_messages(self,data):
self.openai_messages = self.openai_messages[-1:] + self.openai_messages[:-1]
self.openai_messages[0] = data
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def push_user_messages(self,user,data):
self.user_users.append(user)
self.user_messages.append(data)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def similar(self,a,b):
return SequenceMatcher(None,a,b).ratio()
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
@irc3.plugin
class Plugin:
@irc3.plugin
class Plugin:
def __init__(self, bot):
self.bot = bot
@ -109,8 +118,8 @@ class Plugin:
self.flipcolor=False
self.default_load()
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='view')
def ai(self, mask, target, args):
@ -164,16 +173,16 @@ class Plugin:
self.bot.history.bounce={'user':USER,'message':term,'target':target}
break
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def random_float(self,n):
i=float(rint(0,n))
i/=10
return i
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def print_response_properties(self,target):
self.bot.privmsg(target, f"{DRED} model{GREY}: {LRED}{self.default_model}")
@ -183,8 +192,8 @@ class Plugin:
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}")
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def airand(self, mask, target, args):
@ -205,8 +214,8 @@ class Plugin:
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}randomizing personality properties {GREY}>>>"))
self.print_response_properties(target)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def default_load(self):
FILE='%s/../personalities/default.db' % dir_path
@ -216,8 +225,8 @@ class Plugin:
self.start_chat_log=self.start_chat_log[1:]
f.close()
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def airead(self, mask, target, args):
@ -233,8 +242,8 @@ class Plugin:
for __ in msg:
self.bot.privmsg(target, f'{__.strip()}')
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aishow(self, mask, target, args):
@ -244,8 +253,8 @@ class Plugin:
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}showing current personality properties {GREY}>>>"))
self.print_response_properties(target)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aiterm(self, mask, target, args):
@ -258,8 +267,8 @@ class Plugin:
for __ in msg:
self.bot.privmsg(target, f'{__.strip()}')
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def airesponse(self, mask, target, args):
@ -297,8 +306,8 @@ class Plugin:
for _ in msg:
self.bot.privmsg(target, _)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def ailist(self, mask, target, args):
@ -312,8 +321,8 @@ class Plugin:
FILE=_.split('/')[-1].replace('.db','')
self.bot.privmsg(target, f'{DRED}{i}{GREY}: {LRED}{FILE}')
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aiload(self, mask, target, args):
@ -341,8 +350,8 @@ class Plugin:
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
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aiwrite(self, mask, target, args):
@ -363,8 +372,8 @@ class Plugin:
f.close()
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}created {msg} personality database {GREY}>>>"))
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aitrain(self, mask, target, args):
@ -381,8 +390,8 @@ class Plugin:
self.start_chat_log=f'{self.start_chat_log}\n{term}'
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}trained {GREY}>>>"))
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aidefault(self, mask, target, args):
@ -398,8 +407,8 @@ class Plugin:
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}setting personality and properties to defaults {GREY}>>>"))
self.print_response_properties(target)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aiset(self, mask, target, args):
@ -484,8 +493,8 @@ class Plugin:
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}{prop} property set to the value {val} {GREY}>>>"))
self.print_response_properties(target)
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@command(permission='admin')
def aiclear(self, mask, target, args):

@ -1,38 +1,43 @@
# -*- coding: utf-8 -*- ############################################################### SOF
###########################################################################################
???TWITTER???
???YOUTUBE???
###########################################################################################
###########################################################################################
import irc3
from datetime import datetime
import twitter
import re
import os
import sys
import time
import timeago
import os
import requests
from lxml.html import fromstring
from difflib import SequenceMatcher
from plugins.tool_log_plugin import FOG
###########################################################################################
###########################################################################################
####################
if SERVICES_YOUTUBE:
if SERVICES_TWITTER:
####################
import irc3
from datetime import datetime
import twitter
import re
import os
import sys
import time
import timeago
import os
import requests
from lxml.html import fromstring
from difflib import SequenceMatcher
from plugins.tool_log_plugin import FOG
#######################################################################################
#######################################################################################
####################
if SERVICES_YOUTUBE:
####################
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
def getenv(s):
def getenv(s):
try:
s = os.environ[s]
return s
@ -43,52 +48,52 @@ def getenv(s):
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,
access_token_key=TWITTER_ACCESS_TOKEN_KEY, access_token_secret=TWITTER_ACCESS_TOKEN_SECRET)
###########################################################################################
###########################################################################################
#######################################################################################
#######################################################################################
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
class Plugin:
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
class Plugin:
###################################################################################
###################################################################################
def __init__(self, bot):
self.bot = bot
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.extend
def _similar(self, a, b):
return SequenceMatcher(None, a, b).ratio()
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.extend
def _check_for_url(self, og_tweet, d_nick, d_url, d_unrolled, d_text, d_target):
@ -159,8 +164,8 @@ class Plugin:
print("original: {} nick: {} url: {} unrolled: {} text: {} error: {}".format(og_tweet,d_nick,d_url,d_unrolled,d_text,e))
pass
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
def _check_for_twitter(self, mask=None, data=None, target=None, **kw):
match_list = TWITTER_REGEX.findall(data)
@ -242,8 +247,8 @@ class Plugin:
self.bot.privmsg(target, msg)
pass
#######################################################################################
#######################################################################################
###################################################################################
###################################################################################
@irc3.event(irc3.rfc.PRIVMSG)
def on_privmsg_search_for_twitter(self, mask=None, target=None, data=None, **kw):

@ -17,6 +17,7 @@ includes =
plugins.fifo_plugin
plugins.sasl_custom_plugin
plugins.net_hydra_plugin
plugins.tool_log_plugin
plugins.tool_colors_plugin
autojoins =
@ -25,7 +26,7 @@ autojoins =
flood_burst = 0
flood_rate = 1
flood_rate_delay = 1
storage = json://databases/maple_db.json
storage = sqlite://databases/maple_db.sqlite
[plugins.fifo_plugin]
runpath = .fifo

@ -43,6 +43,10 @@
plugins.whoami_plugin
plugins.joke_plugin
plugins.maple_plugin
#plugins.net_hydra_plugin
plugins.openai_plugin
plugins.datetime_plugin
plugins.ip_plugin
plugins.tool_colors_plugin
plugins.tool_log_plugin
plugins.net_hydra_plugin
#plugins.ansi_plugin
#plugins.openai_plugin

@ -1,91 +1,159 @@
# -*- coding: utf-8 -*- ############################################################### SOF
global SERVICES
SERVICES=False
###########################################################################################
???DISCORD???
???TELEGRAM???
???MATRIX???
###########################################################################################
###########################################################################################
import asyncio
import os
import sys
import threading
from time import sleep
##################################################channel##################################
###########################################################################################
###########################################################################################
if SERVICES_MATRIX:
from nio import AsyncClient, MatrixRoom, RoomMessageText
from plugins.net_matrix_plugin import start_matrixbot
###########################################################################################
###########################################################################################
if SERVICES_DISCORD:
from plugins.net_discord_plugin import start_discordbot
###########################################################################################
###########################################################################################
if SERVICES_TELEGRAM:
from plugins.net_telegram_plugin import start_telegrambot
###########################################################################################
###########################################################################################
import irc3
# from nio import AsyncClient, MatrixRoom, RoomMessageText
##################################################channel##################################
# from plugins.net_discord_plugin import start_discordbot
from plugins.net_irc_plugin import config_ircbot, start_ircbot
# from plugins.net_matrix_plugin import start_matrixbot
# from plugins.net_telegram_plugin import start_telegrambot
from plugins.tool_bus_plugin import BUS
from plugins.tool_dims_plugin import dims
from plugins.tool_guds_plugin import guds
#from plugins.tool_colors_plugin import colorform as print
##################################################channel##################################
from plugins.tool_colors_plugin import colorform as print
from plugins.tool_log_plugin import FOG
###########################################################################################
###########################################################################################
fog=FOG().fog
###########################################################################################
###########################################################################################
class BOTIO:
#######################################################################################
#######################################################################################
verbosity=True
log_exit_level=[]
loop=asyncio.get_event_loop()
#######################################################################################
#######################################################################################
def __init__(self):
print(f'<<< ________botio_class >>> [ instantiated ]')
fog(f'instantiated')
self.ircbot=config_ircbot()
self._bio=guds.memory('__main__.bio')
self.net_irc=[]
if SERVICES_MATRIX:
self.net_matrix=[]
if SERVICES_DISCORD:
self.net_discord=[]
self.net_discord_initialized=False
print(f'<<< ________botio_class >>> [ ircbot configured ]')
fog(f'ircbot configured')
#######################################################################################
#######################################################################################
def __boot__irc(self):
print('<<< system_status__info >>> [ booting connection ] - irc')
fog('booting connection - irc')
self=start_ircbot(self)
# #######################################################################################
# def __boot__matrix(self):
# print('<<< system_status__info >>> [ booting connection ] - matrix')
# self=start_matrixbot(self)
# #######################################################################################
# def __boot__discord(self):
# print('<<< system_status__info >>> [ booting connection ] - discord')
# self=start_discordbot(self)
# #######################################################################################
# def __boot__telegram(self):
# print('<<< system_status__info >>> [ booting connection ] - telegram')
# self=start_telegrambot(self)
#######################################################################################
#######################################################################################
def __boot__matrix(self):
fog('booting connection - matrix')
if SERVICES_MATRIX:
self=start_matrixbot(self)
#######################################################################################
#######################################################################################
def __boot__discord(self):
fog('booting connection - discord')
if SERVICES_DISCORD:
self=start_discordbot(self)
#######################################################################################
#######################################################################################
def __boot__telegram(self):
fog('booting connection - telegram')
if SERVICES_TELEGRAM:
self=start_telegrambot(self)
#######################################################################################
#######################################################################################
def __boot__empty(self):
print('<<< system_status__info >>> [ booting connection ] - empty')
fog('booting connection - empty')
#######################################################################################
#######################################################################################
def __main__(self,index):
counter=0
if index==0:
t=threading.Thread(target=self.__boot__irc)
print(f'<<< system_status__info >>> [ thread setup ] - irc')
fog(f'thread setup - irc')
t.start()
print(f'<<< system_status__info >>> [ thread started ] - irc')
# elif index==1:
# t=threading.Thread(target=self.__boot__matrix)
# print(f'<<< system_status__info >>> [ thread setup ] - matrix')
# t.start()
# t.join()
# print(f'<<< system_status__info >>> [ thread started ] - matrix')
# elif index==2:
# t=threading.Thread(target=self.__boot__discord)
# print(f'<<< system_status__info >>> [ thread setup ] - discord')
# t.start()
# t.join()
# print(f'<<< system_status__info >>> [ thread started ] - discord')
# elif index==3:
# t=threading.Thread(target=self.__boot__telegram)
# print(f'<<< system_status__info >>> [ thread setup ] - telegram')
# t.start()
# t.join()
# print(f'<<< system_status__info >>> [ thread started ] - telegram')
fog(f'thread started - irc')
elif index==1:
if SERVICES_MATRIX:
t=threading.Thread(target=self.__boot__matrix)
fog(f'thread setup - matrix')
t.start()
t.join()
fog(f'thread started - matrix')
elif index==2:
if SERVICES_DISCORD:
t=threading.Thread(target=self.__boot__discord)
fog(f'thread setup - discord')
t.start()
t.join()
fog(f'thread started - discord')
elif index==3:
if SERVICES_MATRIX:
t=threading.Thread(target=self.__boot__telegram)
fog(f'thread setup - telegram')
t.start()
t.join()
fog(f'thread started - telegram')
elif index==4:
t=threading.Thread(target=self.__boot__empty)
print(f'<<< system_status__info >>> [ thread setup ] - empty')
fog(f'thread setup - empty')
t.start()
print(f'<<< system_status__info >>> [ thread started ] - empty')
fog(f'thread started - empty')
###########################################################################################
###########################################################################################
if __name__ == '__main__':
print('<<< system_status__info >>> [ main loop ] - startup')
fog('main loop - startup')
bio=BOTIO()
globals()['guds'].memories.append([bio,'maple:__main__.bio'])
for i in range(4):
@ -94,9 +162,11 @@ if __name__ == '__main__':
while True:
counter+=1
if counter<=3:
print(f'<<< system_status__info >>> [ eventloop idler thread ] - not ready - system locked for {str(counter).zfill(2)}/3 seconds')
fog(f'eventloop idler thread - not ready - system locked for {str(counter).zfill(2)}/3 seconds')
if counter==4:
dims.__boot__()
print(f'<<< system_status__info >>> [ eventloop idler thread ] - system ready')
fog(f'eventloop idler thread - system ready')
sleep(1)
###########################################################################################
####################################################################################### EOF

@ -18,6 +18,7 @@
plugins.emote_plugin
plugins.fifo_plugin
plugins.tool_colors_plugin
plugins.tool_log_plugin
plugins.net_hydra_plugin
# plugins.timezonediff_plugin
# plugins.remind_plugin

@ -1,36 +1,71 @@
# -*- coding: utf-8 -*- ############################################################### SOF
###########################################################################################
???DISCORD???
???TELEGRAM???
???MATRIX???
###########################################################################################
###########################################################################################
import asyncio
import os
import sys
import threading
from time import sleep
##################################################channel##################################
###########################################################################################
###########################################################################################
if SERVICES_MATRIX:
from nio import AsyncClient, MatrixRoom, RoomMessageText
from plugins.net_matrix_plugin import start_matrixbot
##################################################channel##################################
###########################################################################################
###########################################################################################
if SERVICES_DISCORD:
from plugins.net_discord_plugin import start_discordbot
###########################################################################################
###########################################################################################
if SERVICES_TELEGRAM:
from plugins.net_telegram_plugin import start_telegrambot
##################################################channel##################################
###########################################################################################
###########################################################################################
import irc3
from plugins.net_irc_plugin import config_ircbot, start_ircbot
from plugins.tool_bus_plugin import BUS
from plugins.tool_dims_plugin import dims
from plugins.tool_guds_plugin import guds
#from plugins.tool_colors_plugin import colorform as print
##################################################channel##################################
from plugins.tool_colors_plugin import colorform as print
from plugins.tool_log_plugin import FOG
###########################################################################################
###########################################################################################
fog=FOG().fog
###########################################################################################
###########################################################################################
class BOTIO:
#######################################################################################
#######################################################################################
verbosity=True
log_exit_level=[]
loop=asyncio.get_event_loop()
#######################################################################################
#######################################################################################
def __init__(self):
print(f'<<< ________botio_class >>> [ instantiated ]')
fog(f'instantiated')
self.ircbot=config_ircbot()
self._bio=guds.memory('__main__.bio')
self.net_irc=[]
@ -38,67 +73,87 @@ class BOTIO:
self.net_matrix=[]
if SERVICES_DISCORD:
self.net_discord=[]
self.net_discord_initialized=False
print(f'<<< ________botio_class >>> [ ircbot configured ]')
fog(f'ircbot configured')
#######################################################################################
#######################################################################################
def __boot__irc(self):
print('<<< system_status__info >>> [ booting connection ] - irc')
fog('booting connection - irc')
self=start_ircbot(self)
#######################################################################################
#######################################################################################
def __boot__matrix(self):
print('<<< system_status__info >>> [ booting connection ] - matrix')
fog('booting connection - matrix')
if SERVICES_MATRIX:
self=start_matrixbot(self)
#######################################################################################
#######################################################################################
def __boot__discord(self):
print('<<< system_status__info >>> [ booting connection ] - discord')
fog('booting connection - discord')
if SERVICES_DISCORD:
self=start_discordbot(self)
#######################################################################################
#######################################################################################
def __boot__telegram(self):
print('<<< system_status__info >>> [ booting connection ] - telegram')
fog('booting connection - telegram')
if SERVICES_TELEGRAM:
self=start_telegrambot(self)
#######################################################################################
#######################################################################################
def __boot__empty(self):
print('<<< system_status__info >>> [ booting connection ] - empty')
fog('booting connection - empty')
#######################################################################################
#######################################################################################
def __main__(self,index):
counter=0
if index==0:
t=threading.Thread(target=self.__boot__irc)
print(f'<<< system_status__info >>> [ thread setup ] - irc')
fog(f'thread setup - irc')
t.start()
print(f'<<< system_status__info >>> [ thread started ] - irc')
fog(f'thread started - irc')
elif index==1:
if SERVICES_MATRIX:
t=threading.Thread(target=self.__boot__matrix)
print(f'<<< system_status__info >>> [ thread setup ] - matrix')
fog(f'thread setup - matrix')
t.start()
t.join()
print(f'<<< system_status__info >>> [ thread started ] - matrix')
fog(f'thread started - matrix')
elif index==2:
if SERVICES_DISCORD:
t=threading.Thread(target=self.__boot__discord)
print(f'<<< system_status__info >>> [ thread setup ] - discord')
fog(f'thread setup - discord')
t.start()
t.join()
print(f'<<< system_status__info >>> [ thread started ] - discord')
fog(f'thread started - discord')
elif index==3:
if SERVICES_MATRIX:
t=threading.Thread(target=self.__boot__telegram)
print(f'<<< system_status__info >>> [ thread setup ] - telegram')
fog(f'thread setup - telegram')
t.start()
t.join()
print(f'<<< system_status__info >>> [ thread started ] - telegram')
fog(f'thread started - telegram')
elif index==4:
t=threading.Thread(target=self.__boot__empty)
print(f'<<< system_status__info >>> [ thread setup ] - empty')
fog(f'thread setup - empty')
t.start()
print(f'<<< system_status__info >>> [ thread started ] - empty')
fog(f'thread started - empty')
###########################################################################################
###########################################################################################
if __name__ == '__main__':
print('<<< system_status__info >>> [ main loop ] - startup')
fog('main loop - startup')
bio=BOTIO()
globals()['guds'].memories.append([bio,'maple:__main__.bio'])
for i in range(4):
@ -107,9 +162,11 @@ if __name__ == '__main__':
while True:
counter+=1
if counter<=3:
print(f'<<< system_status__info >>> [ eventloop idler thread ] - not ready - system locked for {str(counter).zfill(2)}/3 seconds')
fog(f'eventloop idler thread - not ready - system locked for {str(counter).zfill(2)}/3 seconds')
if counter==4:
dims.__boot__()
print(f'<<< system_status__info >>> [ eventloop idler thread ] - system ready')
fog(f'eventloop idler thread - system ready')
sleep(1)
###########################################################################################
####################################################################################### EOF

@ -44,6 +44,9 @@
plugins.whoami_plugin
plugins.joke_plugin
plugins.maple_plugin
plugins.openai_plugin
plugins.datetime_plugin
plugins.ip_plugin
plugins.tool_colors_plugin
plugins.tool_log_plugin
#plugins.ansi_plugin
#plugins.openai_plugin