update
This commit is contained in:
parent
797a912adb
commit
a32c7649fa
330
maple
330
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
|
||||
|
||||
@ -76,19 +68,19 @@ PREREQUISITES_PROGS=(jq nc)
|
||||
FOUND_PROGS=()
|
||||
|
||||
for p in ${PREREQUISITES_PROGS[@]}; do
|
||||
which $p >> /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "\033[0;32mlocated $p\033[0m"
|
||||
else
|
||||
FOUND_PROGS+=("$p")
|
||||
fi
|
||||
which $p >> /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "\033[0;32mlocated $p\033[0m"
|
||||
else
|
||||
FOUND_PROGS+=("$p")
|
||||
fi
|
||||
done
|
||||
|
||||
for p in ${FOUND_PROGS[@]}; do
|
||||
MESSAGE="\033[0;91minstallation required\033[0;0m"
|
||||
##################################################
|
||||
[ "jq" == $p ] && echo -e "\033[0;31mmissing $p -\033[0;34m $MESSAGE"
|
||||
[ "nc" == $p ] && echo -e "\033[0;31mmissing $p -\033[0;34m $MESSAGE"
|
||||
MESSAGE="\033[0;91minstallation required\033[0;0m"
|
||||
##################################################
|
||||
[ "jq" == $p ] && echo -e "\033[0;31mmissing $p -\033[0;34m $MESSAGE"
|
||||
[ "nc" == $p ] && echo -e "\033[0;31mmissing $p -\033[0;34m $MESSAGE"
|
||||
done
|
||||
|
||||
[ 0 -ne "${#FOUND_PROGS[@]}" ] && echo -e "\n\033[0;33m[ PREREQUISITES CHECK - \033[0;33mFAILED \033[0;33m]\033[0m\n"
|
||||
@ -108,36 +100,39 @@ if [ -e preset ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
#####################################################################################################################
|
||||
#####################################################################################################################
|
||||
|
||||
function rgb () {
|
||||
R=$((RANDOM%256))
|
||||
G=$((RANDOM%256))
|
||||
B=$((RANDOM%256))
|
||||
echo -e "\e[38;2;"$R";"$G";"$B"m"
|
||||
R=$((RANDOM%256))
|
||||
G=$((RANDOM%256))
|
||||
B=$((RANDOM%256))
|
||||
echo -e "\e[38;2;"$R";"$G";"$B"m"
|
||||
}
|
||||
|
||||
#####################################################################################################################
|
||||
#####################################################################################################################
|
||||
|
||||
function analyze () {
|
||||
R="$(rgb)"
|
||||
G="$(rgb)"
|
||||
B="$(rgb)"
|
||||
W="$(rgb)"
|
||||
CYCLE=$((CYCLE+1))
|
||||
echo -e "######################################################### SOF"
|
||||
echo -e $W" stage: $CYCLE - ( CONTENT BELOW )"
|
||||
echo -e $B"filename: $1"
|
||||
echo -e $B"filesize: `cat $1|wc -c`"
|
||||
echo -e $G" md5sum: `md5sum $1|cut -c-32`"
|
||||
echo -e $G"fileinfo: `file $1`"
|
||||
echo -e $R"`cat $1|hexdump -C`"|head -n 4
|
||||
echo -e $R"`cat $1|hexdump -C`"|tail -n 4
|
||||
echo -e $B"filename: $1"
|
||||
echo -e $W"stage $CYCLE: ( CONTENT ABOVE )"
|
||||
echo -e "EOF #########################################################"
|
||||
R="$(rgb)"
|
||||
G="$(rgb)"
|
||||
B="$(rgb)"
|
||||
W="$(rgb)"
|
||||
CYCLE=$((CYCLE+1))
|
||||
echo -e "######################################################### SOF"
|
||||
echo -e $W" stage: $CYCLE - ( CONTENT BELOW )"
|
||||
echo -e $B"filename: $1"
|
||||
echo -e $B"filesize: `cat $1|wc -c`"
|
||||
echo -e $G" md5sum: `md5sum $1|cut -c-32`"
|
||||
echo -e $G"fileinfo: `file $1`"
|
||||
echo -e $R"`cat $1|hexdump -C`"|head -n 4
|
||||
echo -e $R"`cat $1|hexdump -C`"|tail -n 4
|
||||
echo -e $B"filename: $1"
|
||||
echo -e $W"stage $CYCLE: ( CONTENT ABOVE )"
|
||||
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 ]"
|
||||
@ -330,9 +328,9 @@ kmodesetup() {
|
||||
echo -e "[ fetching $HYDRA credentials ]"
|
||||
cmd_hydra_undak
|
||||
if [ ! $? -eq 13 ]; then
|
||||
cp data_dack/hydra.key storage/user/config/
|
||||
cp data_dack/maplenet.pub storage/user/config/
|
||||
cp data_dack/maple.pin.asc storage/user/config/
|
||||
cp data_dack/hydra.key storage/user/config/
|
||||
cp data_dack/maplenet.pub storage/user/config/
|
||||
cp data_dack/maple.pin.asc storage/user/config/
|
||||
[ "$MODE" = "1" ] && ( cat data_dack/activate__hydra_core__standalone >> env/bin/activate )
|
||||
[ "$MODE" = "2" ] && ( cat data_dack/activate__hydra_dupe__services >> env/bin/activate )
|
||||
[ "$MODE" = "3" ] && ( cat data_dack/activate__hydra_dupe__devops >> env/bin/activate )
|
||||
@ -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,63 +836,81 @@ 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
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_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
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
else
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/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=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/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=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
fi
|
||||
|
||||
if [ $TELEGRAM__SERVICING -eq 0 ]; then
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=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/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=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/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
else
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/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/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/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/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
fi
|
||||
|
||||
if [ $MATRIX__SERVICING -eq 0 ]; then
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=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/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=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/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
else
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/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/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/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/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
fi
|
||||
|
||||
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/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/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
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
|
||||
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
|
||||
else
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
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
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
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_services_hydra
|
||||
[ -e storage/user/config/hydra.key ] || cmd_hydra;
|
||||
cmd_setup_bot
|
||||
fi;
|
||||
fi;
|
||||
}
|
||||
|
||||
#####################################################################################################################
|
||||
#####################################################################################################################
|
||||
|
||||
cmd_setup_bot () {
|
||||
@ -936,78 +964,78 @@ cmd_setup_bot () {
|
||||
# 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
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_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
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
else
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/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=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/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=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
fi
|
||||
|
||||
if [ $TELEGRAM_SERVICING -eq 0 ]; then
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=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/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=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/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
cat bot_maple.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
else
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/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/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/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/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/net_telegram_plugin.tmp;mv plugins/net_telegram_plugin.tmp plugins/net_telegram_plugin.py
|
||||
cat bot_maple.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
fi
|
||||
|
||||
if [ $MATRIX___SERVICING -eq 0 ]; then
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=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/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=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/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
else
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/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/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/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/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
|
||||
cat plugins/net_matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_matrix_plugin.tmp;mv plugins/net_matrix_plugin.tmp plugins/net_matrix_plugin.py
|
||||
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
|
||||
fi
|
||||
|
||||
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/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
|
||||
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/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
|
||||
fi
|
||||
|
||||
if [ $YOUTUBE__SERVICING -eq 0 ]; then
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
|
||||
else
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
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
|
||||
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=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/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
|
||||
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
|
||||
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
|
||||
|
||||
# injects a myriad of plugins depending on variant
|
||||
cat plugins/net_irc_plugin.py|sed '/includes/r storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt' > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
|
||||
|
||||
fi;
|
||||
elif [ $RESULT -eq 3 ]; then
|
||||
(kmode 3);
|
||||
if [ ! -e plugins ]; then
|
||||
mkdir plugins
|
||||
cat storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt|grep -v "#"|grep -v irc3|sed s/plugins.//|xargs -I{} cp storage/bot/plugins/{}.py plugins/
|
||||
cat plugins/net_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
cat plugins/net_irc_plugin.py|sed '/includes/r storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt' > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
|
||||
fi;
|
||||
fi;
|
||||
@ -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,149 +1,158 @@
|
||||
# -*- 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):
|
||||
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)
|
||||
##########################
|
||||
if SERVICES_CRYPTOCOMPARE:
|
||||
##########################
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
CRYPTOCOMPARE_KEY=getenv('CRYPTOCOMPARE_KEY')
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
headers = { 'authorization': f'Apikey {CRYPTOCOMPARE_KEY}' }
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
import sys
|
||||
from irc3.plugins.command import command
|
||||
import irc3,os,aiohttp, asyncio, async_timeout
|
||||
from plugins.tool_log_plugin import FOG
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@command(permission='view')
|
||||
def cc(self, mask, target, args):
|
||||
"""Show Crypto Value
|
||||
%%cc <coin>
|
||||
"""
|
||||
coin = args['<coin>'].upper()
|
||||
async def fetch(session, url):
|
||||
async with async_timeout.timeout(10):
|
||||
async with session.get(url) as response:
|
||||
return await response.json()
|
||||
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)
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
async def grab_url(url):
|
||||
async with aiohttp.ClientSession(headers=headers) as session:
|
||||
json_response = await fetch(session, url)
|
||||
return json_response
|
||||
CRYPTOCOMPARE_KEY=getenv('CRYPTOCOMPARE_KEY')
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def parse_coin(response):
|
||||
try:
|
||||
task_result, _ = response.result()
|
||||
task1, task2, task3 = task_result
|
||||
rlist = sorted([task1.result(), task2.result(), task3.result()], key=lambda item: len(item.keys()))
|
||||
if rlist[1].get("USD"):
|
||||
price = rlist[1].get("USD")
|
||||
price_multi = rlist[2].get("DISPLAY")[coin].get("USD", {})
|
||||
daily_avg = rlist[0].get("USD")
|
||||
elif rlist[2].get("USD"):
|
||||
price_multi = rlist[1].get("DISPLAY")[coin].get("USD", {})
|
||||
price = rlist[2].get("USD")
|
||||
daily_avg = rlist[0].get("USD")
|
||||
data_dict = {}
|
||||
for k, v in price_multi.items():
|
||||
if isinstance(v, str):
|
||||
v = v.replace("$","").replace(" ","").replace(",","")
|
||||
data_dict[k] = v
|
||||
price_multi = data_dict
|
||||
X = float(daily_avg) # AVERAGE OF THE DAY
|
||||
P = float(price_multi.get('PRICE')) # PRICE CURRENTLY
|
||||
H = float(price_multi.get('HIGHDAY')) # HIGH OF THE DAY
|
||||
L = float(price_multi.get('LOWDAY')) # LOW OF THE DAY
|
||||
A = float(price) # AGGREGATED EXCHANGE
|
||||
Y = float(price_multi.get('CHANGE24HOUR')) # PRICE PERCENT DIFFERENTIAL 24 HOURS AGO
|
||||
C = float(price_multi.get('CHANGEPCT24HOUR'))
|
||||
if C <= 0:
|
||||
C = "\x0304{}\x0F".format(C)
|
||||
else:
|
||||
C = "\x0303{}\x0F".format(C)
|
||||
if Y <= 0:
|
||||
Y = "\x0304{}\x0F".format(Y)
|
||||
else:
|
||||
Y = "\x0303{}\x0F".format(Y)
|
||||
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 = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
except Exception as e:
|
||||
msg = self.bot.emo('their api is glitching: check back later')
|
||||
self.bot.privmsg(target, msg)
|
||||
headers = { 'authorization': f'Apikey {CRYPTOCOMPARE_KEY}' }
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def process_lookups(response):
|
||||
try:
|
||||
html = response.result()
|
||||
except Exception as e:
|
||||
msg = self.bot.emo('site error: {}'.format(e.message))
|
||||
self.bot.privmsg(target, msg)
|
||||
return
|
||||
coin_result = html.get("Data",{}).get(coin, None)
|
||||
if not coin_result:
|
||||
msg = self.bot.emo('Invalid coin - see https://min-api.cryptocompare.com/data/all/coinlist data keys')
|
||||
self.bot.privmsg(target, msg)
|
||||
return
|
||||
day_avg_url = "https://min-api.cryptocompare.com/data/dayAvg?fsym={}&tsym=USD&api_key=94e50805f19646893ee16424918998caad5ec6accff539a23ffee8e546eda4e3".format(coin)
|
||||
price_multi_url = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms={}&tsyms=USD&api_key=94e50805f19646893ee16424918998caad5ec6accff539a23ffee8e546eda4e3".format(coin)
|
||||
price_url = "https://min-api.cryptocompare.com/data/price?fsym={}&tsyms=USD&api_key=94e50805f19646893ee16424918998caad5ec6accff539a23ffee8e546eda4e3".format(coin)
|
||||
tasks = [asyncio.ensure_future(grab_url(day_avg_url)),
|
||||
asyncio.ensure_future(grab_url(price_multi_url)),
|
||||
asyncio.ensure_future(grab_url(price_url))]
|
||||
task = self.bot.create_task(asyncio.wait(tasks))
|
||||
task.add_done_callback(parse_coin)
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
url = "https://min-api.cryptocompare.com/data/all/coinlist"
|
||||
asyncio.ensure_future(grab_url(url), \
|
||||
loop=self.bot.loop).add_done_callback(process_lookups)
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@command(permission='view')
|
||||
def cc(self, mask, target, args):
|
||||
"""Show Crypto Value
|
||||
%%cc <coin>
|
||||
"""
|
||||
coin = args['<coin>'].upper()
|
||||
async def fetch(session, url):
|
||||
async with async_timeout.timeout(10):
|
||||
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:
|
||||
task_result, _ = response.result()
|
||||
task1, task2, task3 = task_result
|
||||
rlist = sorted([task1.result(), task2.result(), task3.result()], key=lambda item: len(item.keys()))
|
||||
if rlist[1].get("USD"):
|
||||
price = rlist[1].get("USD")
|
||||
price_multi = rlist[2].get("DISPLAY")[coin].get("USD", {})
|
||||
daily_avg = rlist[0].get("USD")
|
||||
elif rlist[2].get("USD"):
|
||||
price_multi = rlist[1].get("DISPLAY")[coin].get("USD", {})
|
||||
price = rlist[2].get("USD")
|
||||
daily_avg = rlist[0].get("USD")
|
||||
data_dict = {}
|
||||
for k, v in price_multi.items():
|
||||
if isinstance(v, str):
|
||||
v = v.replace("$","").replace(" ","").replace(",","")
|
||||
data_dict[k] = v
|
||||
price_multi = data_dict
|
||||
X = float(daily_avg) # AVERAGE OF THE DAY
|
||||
P = float(price_multi.get('PRICE')) # PRICE CURRENTLY
|
||||
H = float(price_multi.get('HIGHDAY')) # HIGH OF THE DAY
|
||||
L = float(price_multi.get('LOWDAY')) # LOW OF THE DAY
|
||||
A = float(price) # AGGREGATED EXCHANGE
|
||||
Y = float(price_multi.get('CHANGE24HOUR')) # PRICE PERCENT DIFFERENTIAL 24 HOURS AGO
|
||||
C = float(price_multi.get('CHANGEPCT24HOUR'))
|
||||
if C <= 0:
|
||||
C = "\x0304{}\x0F".format(C)
|
||||
else:
|
||||
C = "\x0303{}\x0F".format(C)
|
||||
if Y <= 0:
|
||||
Y = "\x0304{}\x0F".format(Y)
|
||||
else:
|
||||
Y = "\x0303{}\x0F".format(Y)
|
||||
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 = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
except Exception as e:
|
||||
msg = self.bot.emo('their api is glitching: check back later')
|
||||
self.bot.privmsg(target, msg)
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
def process_lookups(response):
|
||||
try:
|
||||
html = response.result()
|
||||
except Exception as e:
|
||||
msg = self.bot.emo('site error: {}'.format(e.message))
|
||||
self.bot.privmsg(target, msg)
|
||||
return
|
||||
coin_result = html.get("Data",{}).get(coin, None)
|
||||
if not coin_result:
|
||||
msg = self.bot.emo('Invalid coin - see https://min-api.cryptocompare.com/data/all/coinlist data keys')
|
||||
self.bot.privmsg(target, msg)
|
||||
return
|
||||
day_avg_url = "https://min-api.cryptocompare.com/data/dayAvg?fsym={}&tsym=USD&api_key=94e50805f19646893ee16424918998caad5ec6accff539a23ffee8e546eda4e3".format(coin)
|
||||
price_multi_url = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms={}&tsyms=USD&api_key=94e50805f19646893ee16424918998caad5ec6accff539a23ffee8e546eda4e3".format(coin)
|
||||
price_url = "https://min-api.cryptocompare.com/data/price?fsym={}&tsyms=USD&api_key=94e50805f19646893ee16424918998caad5ec6accff539a23ffee8e546eda4e3".format(coin)
|
||||
tasks = [asyncio.ensure_future(grab_url(day_avg_url)),
|
||||
asyncio.ensure_future(grab_url(price_multi_url)),
|
||||
asyncio.ensure_future(grab_url(price_url))]
|
||||
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), \
|
||||
loop=self.bot.loop).add_done_callback(process_lookups)
|
||||
|
||||
###########################################################################################
|
||||
####################################################################################### EOF
|
||||
|
@ -1,215 +1,224 @@
|
||||
# -*- 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:
|
||||
def __init__():
|
||||
dr1p.designation=""
|
||||
dr1p.enforcing=False
|
||||
dr1p.purpose=""
|
||||
dr1p.color=""
|
||||
dr1p.keyid=""
|
||||
dr1p.home=""
|
||||
##################
|
||||
if SERVICES_HYDRA:
|
||||
##################
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
def generate_keyid_token(self,mode=1):
|
||||
if mode:
|
||||
token=""
|
||||
for i in range(3): token+=hex(rint(0,255))[2:].zfill(2).upper()
|
||||
token+=hex(int(datetime.now().timestamp()))[-4:].upper()
|
||||
token=list(token)
|
||||
shuffle(token)
|
||||
token=''.join(token)
|
||||
return token
|
||||
elif not mode:
|
||||
keyid=""
|
||||
for i in range(7): keyid+=hex(rint(0,255))[2:].zfill(2).upper()
|
||||
keyid+=hex(int(datetime.now().timestamp()))[-4:].upper()
|
||||
keyid=list(keyid)
|
||||
shuffle(keyid)
|
||||
keyid=''.join(keyid)
|
||||
return keyid
|
||||
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
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def __init__(self,bot):
|
||||
self.bot=bot
|
||||
class dr1p:
|
||||
def __init__():
|
||||
dr1p.designation=""
|
||||
dr1p.enforcing=False
|
||||
dr1p.purpose=""
|
||||
dr1p.color=""
|
||||
try:
|
||||
dr1p.purpose=os.environ['HYDRA_PURPOSE']
|
||||
dr1p.designation=os.environ['HYDRA_DESIGNATION']
|
||||
dr1p.home=os.environ['HYDRA_HOME']
|
||||
dr1p.enforcing=False
|
||||
except:
|
||||
dr1p.designation="dupe"
|
||||
dr1p.enforcing=False
|
||||
return
|
||||
if dr1p.designation=="core":
|
||||
dr1p.color="\x0304"
|
||||
dr1p.keyid=self.generate_keyid_token(0)
|
||||
dr1p.token=self.generate_keyid_token(1)
|
||||
dr1p.keyid=""
|
||||
dr1p.home=""
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def server_ready(self):
|
||||
if not dr1p.designation=='core':
|
||||
dr1p.token=self.generate_keyid_token()
|
||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - purpose: {dr1p.purpose} - dupe - connected")
|
||||
else:
|
||||
dr1p.keyid=self.generate_keyid_token(0)
|
||||
dr1p.token=self.generate_keyid_token(1)
|
||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - purpose: {dr1p.purpose} - core - connected")
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
def generate_keyid_token(self,mode=1):
|
||||
if mode:
|
||||
token=""
|
||||
for i in range(3): token+=hex(rint(0,255))[2:].zfill(2).upper()
|
||||
token+=hex(int(datetime.now().timestamp()))[-4:].upper()
|
||||
token=list(token)
|
||||
shuffle(token)
|
||||
token=''.join(token)
|
||||
return token
|
||||
elif not mode:
|
||||
keyid=""
|
||||
for i in range(7): keyid+=hex(rint(0,255))[2:].zfill(2).upper()
|
||||
keyid+=hex(int(datetime.now().timestamp()))[-4:].upper()
|
||||
keyid=list(keyid)
|
||||
shuffle(keyid)
|
||||
keyid=''.join(keyid)
|
||||
return keyid
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.event(irc3.rfc.ERR_NICK)
|
||||
def on_errnick(self,srv=None,retcode=None,me=None,nick=None,data=None):
|
||||
if not dr1p.designation=='core': return
|
||||
msg=f'err_nick - srv:{srv} - retcode:{retcode} - me:{me} - nick:{nick} - data:{data}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
def __init__(self,bot):
|
||||
self.bot=bot
|
||||
dr1p.color=""
|
||||
try:
|
||||
dr1p.purpose=os.environ['HYDRA_PURPOSE']
|
||||
dr1p.designation=os.environ['HYDRA_DESIGNATION']
|
||||
dr1p.home=os.environ['HYDRA_HOME']
|
||||
dr1p.enforcing=False
|
||||
except:
|
||||
dr1p.designation="dupe"
|
||||
dr1p.enforcing=False
|
||||
return
|
||||
if dr1p.designation=="core":
|
||||
dr1p.color="\x0304"
|
||||
dr1p.keyid=self.generate_keyid_token(0)
|
||||
dr1p.token=self.generate_keyid_token(1)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.event(irc3.rfc.NEW_NICK)
|
||||
def on_newnick(self,nick=None,new_nick=None):
|
||||
if not dr1p.designation=='core': return
|
||||
if nick==self.bot.config['nick'] or new_nick==self.bot.config['nick']:
|
||||
msg=f'new_nick - nick:{nick} - new_nick:{new_nick}'
|
||||
def server_ready(self):
|
||||
if not dr1p.designation=='core':
|
||||
dr1p.token=self.generate_keyid_token()
|
||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - purpose: {dr1p.purpose} - dupe - connected")
|
||||
else:
|
||||
dr1p.keyid=self.generate_keyid_token(0)
|
||||
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):
|
||||
if not dr1p.designation=='core': return
|
||||
msg=f'err_nick - srv:{srv} - retcode:{retcode} - me:{me} - nick:{nick} - data:{data}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.event(irc3.rfc.CTCP)
|
||||
def on_ctcp(self,mask=None,event=None,target=None,ctcp=None):
|
||||
if not dr1p.designation=='core': return
|
||||
msg=f'ctcpd - mask:{mask} - event:{event} - target:{target} - ctcp:{ctcp}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
@irc3.event(irc3.rfc.NEW_NICK)
|
||||
def on_newnick(self,nick=None,new_nick=None):
|
||||
if not dr1p.designation=='core': return
|
||||
if nick==self.bot.config['nick'] or new_nick==self.bot.config['nick']:
|
||||
msg=f'new_nick - nick:{nick} - new_nick:{new_nick}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.event(irc3.rfc.INVITE)
|
||||
def on_invite(self,mask=None,channel=None):
|
||||
if not dr1p.designation=='core': return
|
||||
msg=f'invited - mask:{mask} - channel:{channel}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
@irc3.event(irc3.rfc.CTCP)
|
||||
def on_ctcp(self,mask=None,event=None,target=None,ctcp=None):
|
||||
if not dr1p.designation=='core': return
|
||||
msg=f'ctcpd - mask:{mask} - event:{event} - target:{target} - ctcp:{ctcp}'
|
||||
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.INVITE)
|
||||
def on_invite(self,mask=None,channel=None):
|
||||
if not dr1p.designation=='core': return
|
||||
msg=f'invited - mask:{mask} - channel:{channel}'
|
||||
self.bot.privmsg("maple",msg.lower())
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.event(irc3.rfc.PRIVMSG)
|
||||
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:
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - purpose: {dr1p.purpose}"
|
||||
self.bot.privmsg(target,msg)
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - hostname: {socket.gethostname()}"
|
||||
self.bot.privmsg(target,msg)
|
||||
for _ in self.bot.config['includes']:
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - hostname: {socket.gethostname()} - plugin: {_}"
|
||||
@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):
|
||||
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}"
|
||||
self.bot.privmsg(target,msg)
|
||||
return
|
||||
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick:
|
||||
data=""
|
||||
return
|
||||
if mask.nick==self.bot.nick and target==self.bot.config['nick'] and dr1p.designation=='core':
|
||||
if data.endswith('dupe - connected'):
|
||||
_keyid=data.split("[")[1].split("]")[0]
|
||||
_diyek=_keyid[::-1]
|
||||
msg=f'[KEYID:{_keyid}] - [DIYEK:{_diyek}] - COLOR:{rint(16,87)}'
|
||||
self.bot.privmsg(self.bot.config['nick'],msg)
|
||||
if mask.nick==self.bot.nick and target==self.bot.config['nick'] and dr1p.designation=='dupe':
|
||||
if not data.find('DIYEK')==-1:
|
||||
_keyid=data.split(":")[1].split("]")[0]
|
||||
if _keyid.lower()==dr1p.keyid.lower():
|
||||
if not data.find("] - [DIYEK:")==-1:
|
||||
_diyek=data.split("] - [DIYEK:")[1].split("]")[0]
|
||||
if _keyid.lower()==_diyek[::-1].lower():
|
||||
_color=int(data.split(" - COLOR:")[1].strip())
|
||||
if not dr1p.color:
|
||||
dr1p.color=f"\x03{str(_color)}"
|
||||
if dr1p.designation=='core':
|
||||
msg=f"{dr1p.color}[maple:{dr1p.keyid}] - "
|
||||
else:
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - hostname: {socket.gethostname()}"
|
||||
self.bot.privmsg(target,msg)
|
||||
for _ in self.bot.config['includes']:
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - hostname: {socket.gethostname()} - plugin: {_}"
|
||||
self.bot.privmsg(target,msg)
|
||||
return
|
||||
if target!=self.bot.config['nick'] and mask.nick==self.bot.nick:
|
||||
data=""
|
||||
return
|
||||
if mask.nick==self.bot.nick and target==self.bot.config['nick'] and dr1p.designation=='core':
|
||||
if data.endswith('dupe - connected'):
|
||||
_keyid=data.split("[")[1].split("]")[0]
|
||||
_diyek=_keyid[::-1]
|
||||
msg=f'[KEYID:{_keyid}] - [DIYEK:{_diyek}] - COLOR:{rint(16,87)}'
|
||||
self.bot.privmsg(self.bot.config['nick'],msg)
|
||||
if mask.nick==self.bot.nick and target==self.bot.config['nick'] and dr1p.designation=='dupe':
|
||||
if not data.find('DIYEK')==-1:
|
||||
_keyid=data.split(":")[1].split("]")[0]
|
||||
if _keyid.lower()==dr1p.keyid.lower():
|
||||
if not data.find("] - [DIYEK:")==-1:
|
||||
_diyek=data.split("] - [DIYEK:")[1].split("]")[0]
|
||||
if _keyid.lower()==_diyek[::-1].lower():
|
||||
_color=int(data.split(" - COLOR:")[1].strip())
|
||||
if not dr1p.color:
|
||||
dr1p.color=f"\x03{str(_color)}"
|
||||
if dr1p.designation=='core':
|
||||
msg=f"{dr1p.color}[maple:{dr1p.keyid}] - "
|
||||
else:
|
||||
try:
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - "
|
||||
except:
|
||||
dr1p.color="\x0303"
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - "
|
||||
if mask.nick!=self.bot.config['nick']:
|
||||
if target!=dr1p.home: return
|
||||
if target==dr1p.home: return
|
||||
msg+=f'event:{event} - mask:{mask} - target:{target} - data:'
|
||||
msg+=f'{data}'
|
||||
if kw: msg+=f" - kw:{kw}"
|
||||
try:
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - "
|
||||
keyid1=msg.split(":")[1].split(']')[0].lower()
|
||||
keyid2=msg.split("] - [")[1].lower()
|
||||
if keyid1==keyid2: self.bot.privmsg(dr1p.home,msg.lower())
|
||||
except:
|
||||
dr1p.color="\x0303"
|
||||
msg=f"{dr1p.color}[hydra:{dr1p.keyid}] - "
|
||||
if mask.nick!=self.bot.config['nick']:
|
||||
if target!=dr1p.home: return
|
||||
if target==dr1p.home: return
|
||||
msg+=f'event:{event} - mask:{mask} - target:{target} - data:'
|
||||
msg+=f'{data}'
|
||||
if kw: msg+=f" - kw:{kw}"
|
||||
try:
|
||||
keyid1=msg.split(":")[1].split(']')[0].lower()
|
||||
keyid2=msg.split("] - [")[1].lower()
|
||||
if keyid1==keyid2: self.bot.privmsg(dr1p.home,msg.lower())
|
||||
except:
|
||||
self.bot.privmsg(dr1p.home,"exception - "+msg.lower())
|
||||
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.MY_PRIVMSG)
|
||||
def on_my_privmsg(self,mask=None,event=None,target=None,data=None,**kw):
|
||||
pass
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
||||
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
||||
target=kw['channel']
|
||||
if mask.nick==self.bot.config['nick']:
|
||||
if kw['event']=='JOIN':
|
||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - joined {target}".lower())
|
||||
if target!=dr1p.home:
|
||||
if dr1p.enforcing:
|
||||
reason=".[d]."
|
||||
self.bot.part(target,reason)
|
||||
self.bot.privmsg("maple",f"parted {target} - {reason}".lower())
|
||||
if kw['event']=='PART':
|
||||
if dr1p.designation=="core":
|
||||
msg=f"[maple:{dr1p.keyid}] -"
|
||||
else:
|
||||
msg=f"[hydra:{dr1p.keyid}] -"
|
||||
self.bot.privmsg(dr1p.home,msg+f"parted {target} - {data}")
|
||||
if kw['event']=='QUIT':
|
||||
if dr1p.designation=="core":
|
||||
msg=f"[maple:{dr1p.keyid}] -"
|
||||
else:
|
||||
msg=f"[hydra:{dr1p.keyid}] -"
|
||||
self.bot.privmsg("maple",msg+f"quit {target} - {data}")
|
||||
@irc3.event(irc3.rfc.JOIN_PART_QUIT)
|
||||
def on_join_part_quit(self,mask=None,target=None,data=None,**kw):
|
||||
target=kw['channel']
|
||||
if mask.nick==self.bot.config['nick']:
|
||||
if kw['event']=='JOIN':
|
||||
self.bot.privmsg("maple",f"[{dr1p.keyid}] - [{dr1p.token}] - joined {target}".lower())
|
||||
if target!=dr1p.home:
|
||||
if dr1p.enforcing:
|
||||
reason=".[d]."
|
||||
self.bot.part(target,reason)
|
||||
self.bot.privmsg("maple",f"parted {target} - {reason}".lower())
|
||||
if kw['event']=='PART':
|
||||
if dr1p.designation=="core":
|
||||
msg=f"[maple:{dr1p.keyid}] -"
|
||||
else:
|
||||
msg=f"[hydra:{dr1p.keyid}] -"
|
||||
self.bot.privmsg(dr1p.home,msg+f"parted {target} - {data}")
|
||||
if kw['event']=='QUIT':
|
||||
if dr1p.designation=="core":
|
||||
msg=f"[maple:{dr1p.keyid}] -"
|
||||
else:
|
||||
msg=f"[hydra:{dr1p.keyid}] -"
|
||||
self.bot.privmsg("maple",msg+f"quit {target} - {data}")
|
||||
|
||||
###########################################################################################
|
||||
####################################################################################### EOF
|
||||
|
@ -1,503 +1,512 @@
|
||||
# -*- 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:
|
||||
###################
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
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"
|
||||
GREY="\x02\x0314"
|
||||
DRED="\x02\x0302"
|
||||
LRED="\x02\x0312"
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
class OPENAI_MESSAGE_HISTORY():
|
||||
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_messages = []
|
||||
user_messages = []
|
||||
user_users = []
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def __init__(self):
|
||||
self.processing=0
|
||||
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)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def push_openai_messages(self,data):
|
||||
self.openai_messages = self.openai_messages[-1:] + self.openai_messages[:-1]
|
||||
self.openai_messages[0] = data
|
||||
OPENAI_KEY = getenv('OPENAI_KEY')
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def push_user_messages(self,user,data):
|
||||
self.user_users.append(user)
|
||||
self.user_messages.append(data)
|
||||
DREY="\x02\x0315"
|
||||
GREY="\x02\x0314"
|
||||
DRED="\x02\x0302"
|
||||
LRED="\x02\x0312"
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def similar(self,a,b):
|
||||
return SequenceMatcher(None,a,b).ratio()
|
||||
class OPENAI_MESSAGE_HISTORY():
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
openai_messages = []
|
||||
user_messages = []
|
||||
user_users = []
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.bot.openai_history=OPENAI_MESSAGE_HISTORY()
|
||||
for _ in range(5):
|
||||
self.bot.openai_history.openai_messages.append("")
|
||||
self.openai_io=[]
|
||||
self.start_chat_log=""
|
||||
self.lastterm=""
|
||||
self.lastresponse=""
|
||||
self.default_model="text-davinci-002"
|
||||
self.temperature=1.1
|
||||
self.max_tokens=2000
|
||||
self.top_p=1.0
|
||||
self.frequency_penalty=0.0
|
||||
self.presence_penalty=0.0
|
||||
self.flipcolor=False
|
||||
self.default_load()
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
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()
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@command(permission='view')
|
||||
def ai(self, mask, target, args):
|
||||
"""OpenAi Question A Term
|
||||
%%ai <term>...
|
||||
"""
|
||||
term=' '.join(args['<term>'])
|
||||
if not term[-1] == ".": term+="."
|
||||
openai.api_key = OPENAI_KEY
|
||||
print(f"<<< openai: processing {target} {mask.nick.lower()} message: {term.lower()}")
|
||||
MESSAGE_OK=True
|
||||
TRAP_OK=True
|
||||
LOOP_COUNT_LIMIT=5
|
||||
LOOP_COUNT=0
|
||||
while MESSAGE_OK:
|
||||
LOOP_COUNT+=1
|
||||
print(f'<<< loop: {LOOP_COUNT} >>>')
|
||||
prompt_text=f'{term}'
|
||||
self.lastterm=f'{term}'
|
||||
response=openai.Completion.create(
|
||||
model=self.default_model,
|
||||
prompt=prompt_text,
|
||||
temperature=self.temperature,
|
||||
max_tokens=self.max_tokens,
|
||||
top_p=self.top_p,
|
||||
frequency_penalty=self.frequency_penalty,
|
||||
presence_penalty=self.presence_penalty
|
||||
)
|
||||
self.lastresponse=response
|
||||
openai_message=response.choices[0].text
|
||||
USER=mask.nick
|
||||
MESSAGE=term
|
||||
if MESSAGE_OK and TRAP_OK:
|
||||
self.bot.openai_history.push_openai_messages(openai_message)
|
||||
_msg = re.findall(r'.{1,400}(?:\s+|$)', openai_message)
|
||||
COLOR=""
|
||||
self.flipcolor = not self.flipcolor
|
||||
if self.flipcolor:
|
||||
COLOR=DREY
|
||||
else:
|
||||
COLOR=GREY
|
||||
for i,_ in enumerate(_msg):
|
||||
if i==0:
|
||||
self.bot.privmsg(target, f"\x02\x0302{USER:}\x0F\x02\x0309 ▶ {COLOR}{_.strip()}\x0F")
|
||||
@irc3.plugin
|
||||
class Plugin:
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.bot.openai_history=OPENAI_MESSAGE_HISTORY()
|
||||
for _ in range(5):
|
||||
self.bot.openai_history.openai_messages.append("")
|
||||
self.openai_io=[]
|
||||
self.start_chat_log=""
|
||||
self.lastterm=""
|
||||
self.lastresponse=""
|
||||
self.default_model="text-davinci-002"
|
||||
self.temperature=1.1
|
||||
self.max_tokens=2000
|
||||
self.top_p=1.0
|
||||
self.frequency_penalty=0.0
|
||||
self.presence_penalty=0.0
|
||||
self.flipcolor=False
|
||||
self.default_load()
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='view')
|
||||
def ai(self, mask, target, args):
|
||||
"""OpenAi Question A Term
|
||||
%%ai <term>...
|
||||
"""
|
||||
term=' '.join(args['<term>'])
|
||||
if not term[-1] == ".": term+="."
|
||||
openai.api_key = OPENAI_KEY
|
||||
print(f"<<< openai: processing {target} {mask.nick.lower()} message: {term.lower()}")
|
||||
MESSAGE_OK=True
|
||||
TRAP_OK=True
|
||||
LOOP_COUNT_LIMIT=5
|
||||
LOOP_COUNT=0
|
||||
while MESSAGE_OK:
|
||||
LOOP_COUNT+=1
|
||||
print(f'<<< loop: {LOOP_COUNT} >>>')
|
||||
prompt_text=f'{term}'
|
||||
self.lastterm=f'{term}'
|
||||
response=openai.Completion.create(
|
||||
model=self.default_model,
|
||||
prompt=prompt_text,
|
||||
temperature=self.temperature,
|
||||
max_tokens=self.max_tokens,
|
||||
top_p=self.top_p,
|
||||
frequency_penalty=self.frequency_penalty,
|
||||
presence_penalty=self.presence_penalty
|
||||
)
|
||||
self.lastresponse=response
|
||||
openai_message=response.choices[0].text
|
||||
USER=mask.nick
|
||||
MESSAGE=term
|
||||
if MESSAGE_OK and TRAP_OK:
|
||||
self.bot.openai_history.push_openai_messages(openai_message)
|
||||
_msg = re.findall(r'.{1,400}(?:\s+|$)', openai_message)
|
||||
COLOR=""
|
||||
self.flipcolor = not self.flipcolor
|
||||
if self.flipcolor:
|
||||
COLOR=DREY
|
||||
else:
|
||||
self.bot.privmsg(target, f"{COLOR}{_.strip()}\x0F")
|
||||
MESSAGE_OK=False
|
||||
print('<<< openai finished >>>')
|
||||
if LOOP_COUNT > LOOP_COUNT_LIMIT:
|
||||
print(f"<<< openai failed: bouncing to mapleai >>>")
|
||||
self.bot.history.bounce={'user':USER,'message':term,'target':target}
|
||||
break
|
||||
COLOR=GREY
|
||||
for i,_ in enumerate(_msg):
|
||||
if i==0:
|
||||
self.bot.privmsg(target, f"\x02\x0302{USER:}\x0F\x02\x0309 ▶ {COLOR}{_.strip()}\x0F")
|
||||
else:
|
||||
self.bot.privmsg(target, f"{COLOR}{_.strip()}\x0F")
|
||||
MESSAGE_OK=False
|
||||
print('<<< openai finished >>>')
|
||||
if LOOP_COUNT > LOOP_COUNT_LIMIT:
|
||||
print(f"<<< openai failed: bouncing to mapleai >>>")
|
||||
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 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}")
|
||||
self.bot.privmsg(target, f"{DRED} temperature{GREY}: {LRED}{self.temperature}")
|
||||
self.bot.privmsg(target, f"{DRED} max_tokens{GREY}: {LRED}{self.max_tokens}")
|
||||
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} presence_penalty{GREY}: {LRED}{self.presence_penalty}")
|
||||
def print_response_properties(self,target):
|
||||
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} max_tokens{GREY}: {LRED}{self.max_tokens}")
|
||||
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} presence_penalty{GREY}: {LRED}{self.presence_penalty}")
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def airand(self, mask, target, args):
|
||||
"""OpenAi Randomize Response Properties
|
||||
%%airand
|
||||
"""
|
||||
MODELS=["text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
|
||||
MODEL=choices(MODELS)[0]
|
||||
TOKEN_CEILING=1000
|
||||
if MODEL==MODELS[0]:
|
||||
TOKEN_CEILING=2000
|
||||
self.default_model=MODEL
|
||||
self.temperature=self.random_float(20)
|
||||
self.max_tokens=rint(1,TOKEN_CEILING)
|
||||
self.top_p=self.random_float(10)
|
||||
self.frequency_penalty=self.random_float(10000)
|
||||
self.presence_penalty=self.random_float(20)
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}randomizing personality properties {GREY}>>>"))
|
||||
self.print_response_properties(target)
|
||||
@command(permission='admin')
|
||||
def airand(self, mask, target, args):
|
||||
"""OpenAi Randomize Response Properties
|
||||
%%airand
|
||||
"""
|
||||
MODELS=["text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
|
||||
MODEL=choices(MODELS)[0]
|
||||
TOKEN_CEILING=1000
|
||||
if MODEL==MODELS[0]:
|
||||
TOKEN_CEILING=2000
|
||||
self.default_model=MODEL
|
||||
self.temperature=self.random_float(20)
|
||||
self.max_tokens=rint(1,TOKEN_CEILING)
|
||||
self.top_p=self.random_float(10)
|
||||
self.frequency_penalty=self.random_float(10000)
|
||||
self.presence_penalty=self.random_float(20)
|
||||
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
|
||||
f=open(FILE,'r')
|
||||
self.start_chat_log=f.read()
|
||||
if self.start_chat_log.find('\n')==0:
|
||||
self.start_chat_log=self.start_chat_log[1:]
|
||||
f.close()
|
||||
def default_load(self):
|
||||
FILE='%s/../personalities/default.db' % dir_path
|
||||
f=open(FILE,'r')
|
||||
self.start_chat_log=f.read()
|
||||
if self.start_chat_log.find('\n')==0:
|
||||
self.start_chat_log=self.start_chat_log[1:]
|
||||
f.close()
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def airead(self, mask, target, args):
|
||||
"""OpenAi Read Current Personality
|
||||
%%airead
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}reading current personality profile {GREY}>>>"))
|
||||
if self.start_chat_log==None:
|
||||
self.bot.privmsg(target,"<NULL>")
|
||||
else:
|
||||
for _ in self.start_chat_log.splitlines():
|
||||
@command(permission='admin')
|
||||
def airead(self, mask, target, args):
|
||||
"""OpenAi Read Current Personality
|
||||
%%airead
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}reading current personality profile {GREY}>>>"))
|
||||
if self.start_chat_log==None:
|
||||
self.bot.privmsg(target,"<NULL>")
|
||||
else:
|
||||
for _ in self.start_chat_log.splitlines():
|
||||
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
||||
for __ in msg:
|
||||
self.bot.privmsg(target, f'{__.strip()}')
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def aishow(self, mask, target, args):
|
||||
"""OpenAi Show Current Personality Properties and Values.
|
||||
%%aishow
|
||||
"""
|
||||
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):
|
||||
"""OpenAi Show Last Term.
|
||||
%%aiterm
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}showing last term query {GREY}>>>'))
|
||||
for _ in self.lastterm.splitlines():
|
||||
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
||||
for __ in msg:
|
||||
self.bot.privmsg(target, f'{__.strip()}')
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def aishow(self, mask, target, args):
|
||||
"""OpenAi Show Current Personality Properties and Values.
|
||||
%%aishow
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}showing current personality properties {GREY}>>>"))
|
||||
self.print_response_properties(target)
|
||||
@command(permission='admin')
|
||||
def airesponse(self, mask, target, args):
|
||||
"""OpenAi Show Last Server Response.
|
||||
%%airesponse
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}showing last openai server response {GREY}>>>'))
|
||||
msg=[]
|
||||
FINISH_REASON=self.lastresponse['choices'][0]['finish_reason']
|
||||
INDEX=self.lastresponse['choices'][0]['index']
|
||||
LOGPROBS=self.lastresponse['choices'][0]['logprobs']
|
||||
TEXT=self.lastresponse['choices'][0]['text'].strip()
|
||||
MODEL=self.lastresponse['model']
|
||||
OBJECT=MODEL=self.lastresponse['object']
|
||||
COMPLETION_TOKENS=MODEL=self.lastresponse['usage']['completion_tokens']
|
||||
PROMPT_TOKENS=MODEL=self.lastresponse['usage']['prompt_tokens']
|
||||
TOTAL_TOKENS=MODEL=self.lastresponse['usage']['total_tokens']
|
||||
_TEXT=re.findall(r'.{1,400}(?:\s+|$)', TEXT)
|
||||
msg.append(f'{DRED}completion_tokens{GREY}: {LRED}{COMPLETION_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}index{GREY}: {LRED}{INDEX}')
|
||||
msg.append(f' {DRED}logprobs{GREY}: {LRED}{LOGPROBS}')
|
||||
if len(_TEXT) > 1:
|
||||
if len(_TEXT[0]) < len(_TEXT[1])//2:
|
||||
print(f'discovered and removed a preface glitch: {_TEXT[0].strip()}')
|
||||
_TEXT.reverse()
|
||||
_TEXT.pop()
|
||||
_TEXT.reverse()
|
||||
for i,_ in enumerate(_TEXT):
|
||||
if i == 0:
|
||||
msg.append(f' {DRED}text{GREY}: {LRED}{_.strip()}')
|
||||
else:
|
||||
msg.append(f'{LRED}{_.strip()}')
|
||||
for _ in msg:
|
||||
self.bot.privmsg(target, _)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def aiterm(self, mask, target, args):
|
||||
"""OpenAi Show Last Term.
|
||||
%%aiterm
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}showing last term query {GREY}>>>'))
|
||||
for _ in self.lastterm.splitlines():
|
||||
msg = re.findall(r'.{1,400}(?:\s+|$)', _)
|
||||
for __ in msg:
|
||||
self.bot.privmsg(target, f'{__.strip()}')
|
||||
@command(permission='admin')
|
||||
def ailist(self, mask, target, args):
|
||||
"""OpenAi List Personalities
|
||||
%%ailist
|
||||
"""
|
||||
PATH='%s/../personalities' % dir_path
|
||||
FILES=glob(f'{PATH}/*.db')
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}listing personality databases {GREY}>>>"))
|
||||
for i,_ in enumerate(FILES):
|
||||
FILE=_.split('/')[-1].replace('.db','')
|
||||
self.bot.privmsg(target, f'{DRED}{i}{GREY}: {LRED}{FILE}')
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def airesponse(self, mask, target, args):
|
||||
"""OpenAi Show Last Server Response.
|
||||
%%airesponse
|
||||
"""
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}showing last openai server response {GREY}>>>'))
|
||||
msg=[]
|
||||
FINISH_REASON=self.lastresponse['choices'][0]['finish_reason']
|
||||
INDEX=self.lastresponse['choices'][0]['index']
|
||||
LOGPROBS=self.lastresponse['choices'][0]['logprobs']
|
||||
TEXT=self.lastresponse['choices'][0]['text'].strip()
|
||||
MODEL=self.lastresponse['model']
|
||||
OBJECT=MODEL=self.lastresponse['object']
|
||||
COMPLETION_TOKENS=MODEL=self.lastresponse['usage']['completion_tokens']
|
||||
PROMPT_TOKENS=MODEL=self.lastresponse['usage']['prompt_tokens']
|
||||
TOTAL_TOKENS=MODEL=self.lastresponse['usage']['total_tokens']
|
||||
_TEXT=re.findall(r'.{1,400}(?:\s+|$)', TEXT)
|
||||
msg.append(f'{DRED}completion_tokens{GREY}: {LRED}{COMPLETION_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}index{GREY}: {LRED}{INDEX}')
|
||||
msg.append(f' {DRED}logprobs{GREY}: {LRED}{LOGPROBS}')
|
||||
if len(_TEXT) > 1:
|
||||
if len(_TEXT[0]) < len(_TEXT[1])//2:
|
||||
print(f'discovered and removed a preface glitch: {_TEXT[0].strip()}')
|
||||
_TEXT.reverse()
|
||||
_TEXT.pop()
|
||||
_TEXT.reverse()
|
||||
for i,_ in enumerate(_TEXT):
|
||||
if i == 0:
|
||||
msg.append(f' {DRED}text{GREY}: {LRED}{_.strip()}')
|
||||
else:
|
||||
msg.append(f'{LRED}{_.strip()}')
|
||||
for _ in msg:
|
||||
self.bot.privmsg(target, _)
|
||||
@command(permission='admin')
|
||||
def aiload(self, mask, target, args):
|
||||
"""OpenAi Load Personalities
|
||||
%%aiload <msg>...
|
||||
"""
|
||||
msg = ''.join(args['<msg>'])
|
||||
try:
|
||||
i=int(msg)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}error{GREY}: {LRED}not an integer, use only numbers of the personality databases {GREY}>>>'))
|
||||
return
|
||||
PATH='%s/../personalities' % dir_path
|
||||
FILES=glob(f'{PATH}/*.db')
|
||||
try:
|
||||
f=open(FILES[i],'r')
|
||||
buffer=f.read().splitlines()
|
||||
f.close()
|
||||
self.start_chat_log='\n'.join(buffer)
|
||||
if self.start_chat_log.find('\n')==0:
|
||||
self.start_chat_log=self.start_chat_log[1:]
|
||||
FILE=FILES[i].split('/')[-1].replace('.db', '')
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}loaded {FILE} personality database {GREY}>>>'))
|
||||
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}>>>'))
|
||||
return
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def ailist(self, mask, target, args):
|
||||
"""OpenAi List Personalities
|
||||
%%ailist
|
||||
"""
|
||||
PATH='%s/../personalities' % dir_path
|
||||
FILES=glob(f'{PATH}/*.db')
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}listing personality databases {GREY}>>>"))
|
||||
for i,_ in enumerate(FILES):
|
||||
FILE=_.split('/')[-1].replace('.db','')
|
||||
self.bot.privmsg(target, f'{DRED}{i}{GREY}: {LRED}{FILE}')
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def aiload(self, mask, target, args):
|
||||
"""OpenAi Load Personalities
|
||||
%%aiload <msg>...
|
||||
"""
|
||||
msg = ''.join(args['<msg>'])
|
||||
try:
|
||||
i=int(msg)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}error{GREY}: {LRED}not an integer, use only numbers of the personality databases {GREY}>>>'))
|
||||
return
|
||||
PATH='%s/../personalities' % dir_path
|
||||
FILES=glob(f'{PATH}/*.db')
|
||||
try:
|
||||
f=open(FILES[i],'r')
|
||||
buffer=f.read().splitlines()
|
||||
@command(permission='admin')
|
||||
def aiwrite(self, mask, target, args):
|
||||
"""OpenAi List Personalities
|
||||
%%aiwrite <msg>...
|
||||
"""
|
||||
msg = ''.join(args['<msg>'])
|
||||
if self.start_chat_log.find('None\n')==0:
|
||||
self.start_chat_log=self.start_chat_log.replace('None\n','')
|
||||
msg=msg.replace('.','').replace('/','')
|
||||
PATH='%s/../personalities' % dir_path
|
||||
FILE=f'{PATH}/{msg}.db'
|
||||
if os.path.exists(FILE):
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}personality database already exists, choose a different filename {GREY}>>>"))
|
||||
return
|
||||
f=open(FILE, "a")
|
||||
f.write(f'{self.start_chat_log}\n')
|
||||
f.close()
|
||||
self.start_chat_log='\n'.join(buffer)
|
||||
if self.start_chat_log.find('\n')==0:
|
||||
self.start_chat_log=self.start_chat_log[1:]
|
||||
FILE=FILES[i].split('/')[-1].replace('.db', '')
|
||||
self.bot.privmsg(target, self.bot.emo(f'{GREY}<<< {DRED}loaded {FILE} personality database {GREY}>>>'))
|
||||
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}>>>'))
|
||||
return
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}created {msg} personality database {GREY}>>>"))
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def aiwrite(self, mask, target, args):
|
||||
"""OpenAi List Personalities
|
||||
%%aiwrite <msg>...
|
||||
"""
|
||||
msg = ''.join(args['<msg>'])
|
||||
if self.start_chat_log.find('None\n')==0:
|
||||
self.start_chat_log=self.start_chat_log.replace('None\n','')
|
||||
msg=msg.replace('.','').replace('/','')
|
||||
PATH='%s/../personalities' % dir_path
|
||||
FILE=f'{PATH}/{msg}.db'
|
||||
if os.path.exists(FILE):
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}personality database already exists, choose a different filename {GREY}>>>"))
|
||||
return
|
||||
f=open(FILE, "a")
|
||||
f.write(f'{self.start_chat_log}\n')
|
||||
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):
|
||||
"""OpenAi Question A Term
|
||||
%%aitrain <term>...
|
||||
"""
|
||||
term = ' '.join(args['<term>'])
|
||||
if term[-1]==',': term=term[::-1].replace(',','')[::-1]
|
||||
if not term[-1] == ".": term+="."
|
||||
FILE='%s/../personalities/trained.db' % dir_path
|
||||
f=open(FILE, "a")
|
||||
f.write(f'{term}\n')
|
||||
f.close()
|
||||
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 aitrain(self, mask, target, args):
|
||||
"""OpenAi Question A Term
|
||||
%%aitrain <term>...
|
||||
"""
|
||||
term = ' '.join(args['<term>'])
|
||||
if term[-1]==',': term=term[::-1].replace(',','')[::-1]
|
||||
if not term[-1] == ".": term+="."
|
||||
FILE='%s/../personalities/trained.db' % dir_path
|
||||
f=open(FILE, "a")
|
||||
f.write(f'{term}\n')
|
||||
f.close()
|
||||
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):
|
||||
"""OpenAi Return to Defaults
|
||||
%%aidefault
|
||||
"""
|
||||
self.default_model="text-davinci-002"
|
||||
self.temperature=1.1
|
||||
self.max_tokens=2000
|
||||
self.top_p=1.0
|
||||
self.frequency_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.print_response_properties(target)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
def aidefault(self, mask, target, args):
|
||||
"""OpenAi Return to Defaults
|
||||
%%aidefault
|
||||
"""
|
||||
self.default_model="text-davinci-002"
|
||||
self.temperature=1.1
|
||||
self.max_tokens=2000
|
||||
self.top_p=1.0
|
||||
self.frequency_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.print_response_properties(target)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@command(permission='admin')
|
||||
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
|
||||
%%aiset <msg>...
|
||||
"""
|
||||
msg= ' '.join(args['<msg>'])
|
||||
PROPERTIES=['model','temperature','max_tokens','top_p','frequency_penalty','presence_penalty']
|
||||
MODELS=["text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
|
||||
prop=""
|
||||
val=""
|
||||
try:
|
||||
prop=msg.split()[0].lower()
|
||||
val=msg.split()[1].lower()
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}not enough parameters {GREY}- {DRED}property choices{GREY}: {LRED}{PROPERTIES} {GREY}- {DRED}model choices{GREY}: {LRED}{MODELS} {GREY}- {DRED}usage examples{GREY}: {LRED}?aiset model text-davinci-002, ?aiset max_tokens 2000, ?aiset model text-davinci-002, ?aiset temperature 0.7, ?aiset top_p 1.0, ?aiset frequency_penalty 0.0, ?aiset presence_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
if prop in PROPERTIES:
|
||||
if prop == "model":
|
||||
try:
|
||||
if val in MODELS:
|
||||
self.default_model=val
|
||||
if str(val)==MODELS[0]:
|
||||
self.max_tokens = 2000
|
||||
@command(permission='admin')
|
||||
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
|
||||
%%aiset <msg>...
|
||||
"""
|
||||
msg= ' '.join(args['<msg>'])
|
||||
PROPERTIES=['model','temperature','max_tokens','top_p','frequency_penalty','presence_penalty']
|
||||
MODELS=["text-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
|
||||
prop=""
|
||||
val=""
|
||||
try:
|
||||
prop=msg.split()[0].lower()
|
||||
val=msg.split()[1].lower()
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}not enough parameters {GREY}- {DRED}property choices{GREY}: {LRED}{PROPERTIES} {GREY}- {DRED}model choices{GREY}: {LRED}{MODELS} {GREY}- {DRED}usage examples{GREY}: {LRED}?aiset model text-davinci-002, ?aiset max_tokens 2000, ?aiset model text-davinci-002, ?aiset temperature 0.7, ?aiset top_p 1.0, ?aiset frequency_penalty 0.0, ?aiset presence_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
if prop in PROPERTIES:
|
||||
if prop == "model":
|
||||
try:
|
||||
if val in MODELS:
|
||||
self.default_model=val
|
||||
if str(val)==MODELS[0]:
|
||||
self.max_tokens = 2000
|
||||
else:
|
||||
self.max_tokens = 1000
|
||||
else:
|
||||
self.max_tokens = 1000
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property model value should be a string {GREY}- {DRED}choice of models{GREY}: {LRED}{MODELS} {GREY}- {DRED}example{GREY}: {LRED}?aiset model text-davinci-002 {GREY}>>>"))
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property model value should be a string {GREY}- {DRED}choice of models{GREY}: {LRED}{MODELS} {GREY}- {DRED}example{GREY}: {LRED}?aiset model text-davinci-002 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "temperature":
|
||||
try:
|
||||
if float(val) <= 2 and float(val) >= 0:
|
||||
self.temperature=float(val)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property temperature value should be a float {GREY}- {DRED}example{GREY}: {LRED}?aiset temperature 0.7 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "max_tokens":
|
||||
try:
|
||||
if int(val) <= 2000 and int(val) >= 100:
|
||||
self.max_tokens=int(val)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property max_tokens value should be an integer not greater than 2000 {GREY}- {DRED}example{GREY}: {LRED}?aiset max_tokens 2000 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "top_p":
|
||||
try:
|
||||
if float(val) <= 1.0 and float(val) >= 0.0:
|
||||
self.top_p=float(val)
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: property model should be a float no greater than 1.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset top_p 0.7 {GREY}>>>"))
|
||||
return
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: property model should be a float no greater than 1.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset top_p 0.7 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "frequency_penalty":
|
||||
try:
|
||||
if float(val):
|
||||
self.frequency_penalty=float(val)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property frequency_penalty should be a float {GREY}- {DRED}example{GREY}: {LRED}?aiset frequency_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "presence_penalty":
|
||||
try:
|
||||
if float(val) <= 2.0 and float(val) >= 0.0:
|
||||
self.presence_penalty=float(val)
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property presence_penalty should be a float no greater than 2.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset presence_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property presence_penalty should be a float no greater than 2.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset presence_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property model value should be a string {GREY}- {DRED}choice of models{GREY}: {LRED}{MODELS} {GREY}- {DRED}example{GREY}: {LRED}?aiset model text-davinci-002 {GREY}>>>"))
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property model value should be a string {GREY}- {DRED}choice of models{GREY}: {LRED}{MODELS} {GREY}- {DRED}example{GREY}: {LRED}?aiset model text-davinci-002 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "temperature":
|
||||
try:
|
||||
if float(val) <= 2 and float(val) >= 0:
|
||||
self.temperature=float(val)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property temperature value should be a float {GREY}- {DRED}example{GREY}: {LRED}?aiset temperature 0.7 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "max_tokens":
|
||||
try:
|
||||
if int(val) <= 2000 and int(val) >= 100:
|
||||
self.max_tokens=int(val)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property max_tokens value should be an integer not greater than 2000 {GREY}- {DRED}example{GREY}: {LRED}?aiset max_tokens 2000 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "top_p":
|
||||
try:
|
||||
if float(val) <= 1.0 and float(val) >= 0.0:
|
||||
self.top_p=float(val)
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: property model should be a float no greater than 1.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset top_p 0.7 {GREY}>>>"))
|
||||
return
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: property model should be a float no greater than 1.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset top_p 0.7 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "frequency_penalty":
|
||||
try:
|
||||
if float(val):
|
||||
self.frequency_penalty=float(val)
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property frequency_penalty should be a float {GREY}- {DRED}example{GREY}: {LRED}?aiset frequency_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
elif prop == "presence_penalty":
|
||||
try:
|
||||
if float(val) <= 2.0 and float(val) >= 0.0:
|
||||
self.presence_penalty=float(val)
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property presence_penalty should be a float no greater than 2.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset presence_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
except:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}property presence_penalty should be a float no greater than 2.0 {GREY}- {DRED}example{GREY}: {LRED}?aiset presence_penalty 0.0 {GREY}>>>"))
|
||||
return
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}no properties were set, they remain the same {GREY}>>>"))
|
||||
self.print_response_properties(target)
|
||||
return
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}used an invalid property identifier {GREY}- {DRED}property identifiers are {LRED}{PROPERTIES} {GREY}>>>"))
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}no properties were set, they remain the same {GREY}>>>"))
|
||||
self.print_response_properties(target)
|
||||
return
|
||||
else:
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}used an invalid property identifier {GREY}- {DRED}property identifiers are {LRED}{PROPERTIES} {GREY}>>>"))
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}error{GREY}: {LRED}no properties were set, they remain the same {GREY}>>>"))
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}{prop} property set to the value {val} {GREY}>>>"))
|
||||
self.print_response_properties(target)
|
||||
return
|
||||
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):
|
||||
"""OpenAi Clear Term
|
||||
%%aiclear
|
||||
"""
|
||||
FILE='%s/../personalities/trained.db' % dir_path
|
||||
f=open(FILE, "w")
|
||||
f.write("")
|
||||
f.close()
|
||||
self.start_chat_log = ""
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}cleared {GREY}>>>"))
|
||||
@command(permission='admin')
|
||||
def aiclear(self, mask, target, args):
|
||||
"""OpenAi Clear Term
|
||||
%%aiclear
|
||||
"""
|
||||
FILE='%s/../personalities/trained.db' % dir_path
|
||||
f=open(FILE, "w")
|
||||
f.write("")
|
||||
f.close()
|
||||
self.start_chat_log = ""
|
||||
self.bot.privmsg(target, self.bot.emo(f"{GREY}<<< {DRED}cleared {GREY}>>>"))
|
||||
|
||||
###########################################################################################
|
||||
####################################################################################### EOF
|
||||
|
@ -1,255 +1,260 @@
|
||||
# -*- 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:
|
||||
####################
|
||||
|
||||
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
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)
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
||||
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:
|
||||
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
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
####################
|
||||
if SERVICES_YOUTUBE:
|
||||
####################
|
||||
|
||||
YOUTUBE_REGEX = re.compile('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', re.IGNORECASE)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@irc3.extend
|
||||
def _similar(self, a, b):
|
||||
return SequenceMatcher(None, a, b).ratio()
|
||||
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)
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
@irc3.extend
|
||||
def _check_for_url(self, og_tweet, d_nick, d_url, d_unrolled, d_text, d_target):
|
||||
match_list = URL_REGEX.findall(d_unrolled)
|
||||
read_size = 0
|
||||
if match_list:
|
||||
url = match_list.pop()
|
||||
try:
|
||||
if not d_unrolled.find('https://twitter.com/') == -1:
|
||||
if not d_unrolled.find('status') == -1:
|
||||
try:
|
||||
e_status = d_unrolled.split('/')[-1]
|
||||
e_tweet = twitter.GetStatus(e_status)
|
||||
e_text = e_tweet.text
|
||||
if self._similar(og_tweet.text,e_text) > 0.7: return
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0303 >> {e_text:} \x0F".format(nick1=d_nick,nick2='UNROLLED',e_text=e_text)
|
||||
if e_tweet.media:
|
||||
for y in range(len(e_tweet.media)):
|
||||
m_turl = e_tweet.media[y].url
|
||||
m_murl = e_tweet.media[y].media_url
|
||||
m_eurl = e_tweet.media[y].expanded_url
|
||||
msg = msg + " >> [media] \x0F\x02\x0312{media_url:}".format(media_url=m_murl)
|
||||
if e_tweet.urls:
|
||||
for y in range(len(e_tweet.urls)):
|
||||
e_turl = e_tweet.urls[y].url
|
||||
e_eurl = e_tweet.urls[y].expanded_url
|
||||
msg = msg + " >> [url] \x0F\x02\x0312{e_url:}".format(e_url=e_eurl)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
except Exception as e:
|
||||
msg = "wu/tang >>>>>>>>>>> sub-unrolling: {}".format(e)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
r = requests.get(d_unrolled, timeout=3, stream=True)
|
||||
content_type = r.headers.get("Content-Type")
|
||||
content_length = r.headers.get('Content-Length')
|
||||
if not content_length:
|
||||
content_length = 0
|
||||
if content_type.startswith('image'):
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0303 >> [media] {media:} \x0F".format(nick1=d_nick,nick2='UNROLLED',media=d_unrolled)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
if not content_type.startswith("text/html"):
|
||||
return
|
||||
if int(content_length) > 200000:
|
||||
self.bot.privmsg(d_target, "pre-fetch aborted -> fuck your large ass content -> {} -> {}".format(d_url,d_unrolled))
|
||||
while read_size <= (2000 * 10):
|
||||
for content in r.iter_content(chunk_size=2000):
|
||||
tree = fromstring(content)
|
||||
title = tree.find(".//title")
|
||||
if title is not None:
|
||||
title = title.text.strip()[:100]
|
||||
print('title: {}'.format(title))
|
||||
similarity = self.bot._similar(title,d_text)
|
||||
if similarity > 0.4:
|
||||
print('wu/tang: similarity')
|
||||
return
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0304 >> \x0F\x1D\x0314{url:}\x0F\x0304 >> \x0F\x0303{unrolled:} \x0F\x0304>> \x0F\x1D\x0314{title:}\x0F".format(nick1=d_nick,nick2='UNROLLED',url=d_url,unrolled=d_unrolled,title=title)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
read_size = read_size + 2000
|
||||
except Exception as 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))
|
||||
pass
|
||||
|
||||
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')
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def _check_for_twitter(self, mask=None, data=None, target=None, **kw):
|
||||
match_list = TWITTER_REGEX.findall(data)
|
||||
if match_list:
|
||||
status_id = match_list[0][2]
|
||||
try:
|
||||
tweet = twitter.GetStatus(status_id=status_id)
|
||||
tweet_text = tweet.text
|
||||
user = tweet.user.screen_name
|
||||
fav_count = tweet.favorite_count
|
||||
retweet_count = tweet.retweet_count
|
||||
if tweet.coordinates:
|
||||
location = tweet.coordinates
|
||||
else:
|
||||
location = ""
|
||||
tweet_time = time.strptime(tweet.created_at, '%a %b %d %H:%M:%S +0000 %Y')
|
||||
time_since = timeago.format(time.strftime('%Y-%m-%d %H:%M:%S', tweet_time), datetime.now())
|
||||
msg = "\x02\x0302{} \x0F\x0303>\x0F \x02\x0301{}\x0F\x0314 | Retweets:\x0F \x1D\x0306{}\x0F\x0314 Favorites:\x0F\x1D\x0306 {} \x0F⑆\x1D\x0314\x1D {} {}".format(user, tweet_text, retweet_count, fav_count, time_since, location)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
match_list = URL_REGEX.findall(msg)
|
||||
|
||||
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:
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
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):
|
||||
match_list = URL_REGEX.findall(d_unrolled)
|
||||
read_size = 0
|
||||
if match_list:
|
||||
url = match_list.pop()
|
||||
try:
|
||||
if(match_list):
|
||||
try:
|
||||
if len(tweet.urls) == 0:
|
||||
if tweet.media:
|
||||
for y in range(len(tweet.media)):
|
||||
m_turl = tweet.media[y].url
|
||||
m_murl = tweet.media[y].media_url
|
||||
m_eurl = tweet.media[y].expanded_url
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0304 >> [media] \x0F\x02\x0312{m_turl:}\x0F\x0304 >> \x0F\x0303{m_murl:} \x0F\x0304>> \x0F\x1D\x0314{m_eurl:}\x0F".format(nick1=user,nick2='UNROLLED',m_turl=m_turl,m_murl=m_murl,m_eurl=m_eurl)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
else:
|
||||
for y in range(len(tweet.urls)):
|
||||
t_turl = tweet.urls[y].url
|
||||
try:
|
||||
match_list.remove(t_turl)
|
||||
except:
|
||||
print('cant remove from matchlist, does not exist')
|
||||
t_eurl = tweet.urls[y].expanded_url
|
||||
|
||||
####################
|
||||
if SERVICES_YOUTUBE:
|
||||
####################
|
||||
|
||||
yt_match_list = YOUTUBE_REGEX.findall(t_eurl)
|
||||
if yt_match_list:
|
||||
d_video_id = t_eurl.split('=')[1]
|
||||
self.bot.madjust = "{}:UNROLLED".format(user)
|
||||
self.bot.yt(mask,target,{'<keyword>': [d_video_id],'yt': True})
|
||||
self.bot.madjust = ""
|
||||
|
||||
else:
|
||||
if not str(tweet.id) == t_eurl.split('/')[-1]:
|
||||
self.bot._check_for_url(tweet,user,t_turl,t_eurl,tweet_text,target)
|
||||
else:
|
||||
print('bypassing original tweet')
|
||||
if not d_unrolled.find('https://twitter.com/') == -1:
|
||||
if not d_unrolled.find('status') == -1:
|
||||
try:
|
||||
if len(match_list) > 0:
|
||||
print('items in matchlist remain')
|
||||
print(match_list)
|
||||
except:
|
||||
print('errrororororororo: cant remove from matchlist, does not exist')
|
||||
except Exception as e:
|
||||
self.bot.privmsg(target,'twitter_plugin <> _debug_unrolling -> wu/tang: {}'.format(e))
|
||||
e_status = d_unrolled.split('/')[-1]
|
||||
e_tweet = twitter.GetStatus(e_status)
|
||||
e_text = e_tweet.text
|
||||
if self._similar(og_tweet.text,e_text) > 0.7: return
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0303 >> {e_text:} \x0F".format(nick1=d_nick,nick2='UNROLLED',e_text=e_text)
|
||||
if e_tweet.media:
|
||||
for y in range(len(e_tweet.media)):
|
||||
m_turl = e_tweet.media[y].url
|
||||
m_murl = e_tweet.media[y].media_url
|
||||
m_eurl = e_tweet.media[y].expanded_url
|
||||
msg = msg + " >> [media] \x0F\x02\x0312{media_url:}".format(media_url=m_murl)
|
||||
if e_tweet.urls:
|
||||
for y in range(len(e_tweet.urls)):
|
||||
e_turl = e_tweet.urls[y].url
|
||||
e_eurl = e_tweet.urls[y].expanded_url
|
||||
msg = msg + " >> [url] \x0F\x02\x0312{e_url:}".format(e_url=e_eurl)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
except Exception as e:
|
||||
msg = "wu/tang >>>>>>>>>>> sub-unrolling: {}".format(e)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
r = requests.get(d_unrolled, timeout=3, stream=True)
|
||||
content_type = r.headers.get("Content-Type")
|
||||
content_length = r.headers.get('Content-Length')
|
||||
if not content_length:
|
||||
content_length = 0
|
||||
if content_type.startswith('image'):
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0303 >> [media] {media:} \x0F".format(nick1=d_nick,nick2='UNROLLED',media=d_unrolled)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
if not content_type.startswith("text/html"):
|
||||
return
|
||||
if int(content_length) > 200000:
|
||||
self.bot.privmsg(d_target, "pre-fetch aborted -> fuck your large ass content -> {} -> {}".format(d_url,d_unrolled))
|
||||
while read_size <= (2000 * 10):
|
||||
for content in r.iter_content(chunk_size=2000):
|
||||
tree = fromstring(content)
|
||||
title = tree.find(".//title")
|
||||
if title is not None:
|
||||
title = title.text.strip()[:100]
|
||||
print('title: {}'.format(title))
|
||||
similarity = self.bot._similar(title,d_text)
|
||||
if similarity > 0.4:
|
||||
print('wu/tang: similarity')
|
||||
return
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0304 >> \x0F\x1D\x0314{url:}\x0F\x0304 >> \x0F\x0303{unrolled:} \x0F\x0304>> \x0F\x1D\x0314{title:}\x0F".format(nick1=d_nick,nick2='UNROLLED',url=d_url,unrolled=d_unrolled,title=title)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(d_target, msg)
|
||||
return
|
||||
read_size = read_size + 2000
|
||||
except Exception as e:
|
||||
self.bot.privmsg(target,'twitter_plugin <> wu/tang: {}'.format(e))
|
||||
except Exception as e:
|
||||
_msg = e.message[0]['message']
|
||||
_code = e.message[0]['code']
|
||||
_erid = ''
|
||||
if _code == 179:
|
||||
_erid = "PROTECTED TW33T"
|
||||
else:
|
||||
_erid = "DON'T CARE EXCEPTION"
|
||||
msg = "\x02\x0302{} \x0F\x0304> \x0F\x02\x0312{} aka {}\x0F\x0303".format(_code,_msg,_erid)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
pass
|
||||
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))
|
||||
pass
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
def _check_for_twitter(self, mask=None, data=None, target=None, **kw):
|
||||
match_list = TWITTER_REGEX.findall(data)
|
||||
if match_list:
|
||||
status_id = match_list[0][2]
|
||||
try:
|
||||
tweet = twitter.GetStatus(status_id=status_id)
|
||||
tweet_text = tweet.text
|
||||
user = tweet.user.screen_name
|
||||
fav_count = tweet.favorite_count
|
||||
retweet_count = tweet.retweet_count
|
||||
if tweet.coordinates:
|
||||
location = tweet.coordinates
|
||||
else:
|
||||
location = ""
|
||||
tweet_time = time.strptime(tweet.created_at, '%a %b %d %H:%M:%S +0000 %Y')
|
||||
time_since = timeago.format(time.strftime('%Y-%m-%d %H:%M:%S', tweet_time), datetime.now())
|
||||
msg = "\x02\x0302{} \x0F\x0303>\x0F \x02\x0301{}\x0F\x0314 | Retweets:\x0F \x1D\x0306{}\x0F\x0314 Favorites:\x0F\x1D\x0306 {} \x0F⑆\x1D\x0314\x1D {} {}".format(user, tweet_text, retweet_count, fav_count, time_since, location)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
match_list = URL_REGEX.findall(msg)
|
||||
try:
|
||||
if(match_list):
|
||||
try:
|
||||
if len(tweet.urls) == 0:
|
||||
if tweet.media:
|
||||
for y in range(len(tweet.media)):
|
||||
m_turl = tweet.media[y].url
|
||||
m_murl = tweet.media[y].media_url
|
||||
m_eurl = tweet.media[y].expanded_url
|
||||
msg = "\x02\x0302{nick1:}:{nick2:}\x0F\x02\x0304 >> [media] \x0F\x02\x0312{m_turl:}\x0F\x0304 >> \x0F\x0303{m_murl:} \x0F\x0304>> \x0F\x1D\x0314{m_eurl:}\x0F".format(nick1=user,nick2='UNROLLED',m_turl=m_turl,m_murl=m_murl,m_eurl=m_eurl)
|
||||
msg = self.bot.emo(msg)
|
||||
self.bot.privmsg(target, msg)
|
||||
else:
|
||||
for y in range(len(tweet.urls)):
|
||||
t_turl = tweet.urls[y].url
|
||||
try:
|
||||
match_list.remove(t_turl)
|
||||
except:
|
||||
print('cant remove from matchlist, does not exist')
|
||||
t_eurl = tweet.urls[y].expanded_url
|
||||
|
||||
#######################################################################################
|
||||
#######################################################################################
|
||||
####################
|
||||
if SERVICES_YOUTUBE:
|
||||
####################
|
||||
|
||||
@irc3.event(irc3.rfc.PRIVMSG)
|
||||
def on_privmsg_search_for_twitter(self, mask=None, target=None, data=None, **kw):
|
||||
if data.startswith("?"): return
|
||||
if mask.nick.lower() not in self.bot.ignore_list:
|
||||
self._check_for_twitter(mask, data, target)
|
||||
yt_match_list = YOUTUBE_REGEX.findall(t_eurl)
|
||||
if yt_match_list:
|
||||
d_video_id = t_eurl.split('=')[1]
|
||||
self.bot.madjust = "{}:UNROLLED".format(user)
|
||||
self.bot.yt(mask,target,{'<keyword>': [d_video_id],'yt': True})
|
||||
self.bot.madjust = ""
|
||||
|
||||
else:
|
||||
if not str(tweet.id) == t_eurl.split('/')[-1]:
|
||||
self.bot._check_for_url(tweet,user,t_turl,t_eurl,tweet_text,target)
|
||||
else:
|
||||
print('bypassing original tweet')
|
||||
try:
|
||||
if len(match_list) > 0:
|
||||
print('items in matchlist remain')
|
||||
print(match_list)
|
||||
except:
|
||||
print('errrororororororo: cant remove from matchlist, does not exist')
|
||||
except Exception as e:
|
||||
self.bot.privmsg(target,'twitter_plugin <> _debug_unrolling -> wu/tang: {}'.format(e))
|
||||
except Exception as e:
|
||||
self.bot.privmsg(target,'twitter_plugin <> wu/tang: {}'.format(e))
|
||||
except Exception as e:
|
||||
_msg = e.message[0]['message']
|
||||
_code = e.message[0]['code']
|
||||
_erid = ''
|
||||
if _code == 179:
|
||||
_erid = "PROTECTED TW33T"
|
||||
else:
|
||||
_erid = "DON'T CARE EXCEPTION"
|
||||
msg = "\x02\x0302{} \x0F\x0304> \x0F\x02\x0312{} aka {}\x0F\x0303".format(_code,_msg,_erid)
|
||||
msg = self.bot.emo(msg)
|
||||
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):
|
||||
if data.startswith("?"): return
|
||||
if mask.nick.lower() not in self.bot.ignore_list:
|
||||
self._check_for_twitter(mask, data, target)
|
||||
|
||||
###########################################################################################
|
||||
####################################################################################### EOF
|
||||
|
@ -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=[]
|
||||
self.net_matrix=[]
|
||||
self.net_discord=[]
|
||||
self.net_discord_initialized=False
|
||||
print(f'<<< ________botio_class >>> [ ircbot configured ]')
|
||||
if SERVICES_MATRIX:
|
||||
self.net_matrix=[]
|
||||
if SERVICES_DISCORD:
|
||||
self.net_discord=[]
|
||||
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')
|
||||
if SERVICES_MATRIX:
|
||||
self=start_matrixbot(self)
|
||||
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
|
||||
|
||||
###########################################################################################
|
||||
####################################################################################### 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
|
||||
|
Loading…
Reference in New Issue
Block a user