This commit is contained in:
0xd3d0c3d 2022-07-27 00:17:33 -05:00
parent cc12a92170
commit 4d3dd72494
4 changed files with 64 additions and 12 deletions

@ -10,7 +10,6 @@ from typing import Type
import random
import string
import os
import ipdb
######################################################################################################### THE ASCII LOGO TO BE USED
MOTD="""
_________ _________ _________ ___ ___ _________ _________ ____ ____
@ -136,6 +135,7 @@ class Plugin:
elif command=='all':
mode_length=self.bot.bbs.floor__top_songs
#####################################################################################
top_songs=[]
for i in range(mode_length):
try:
base=bbs_data[nl[i][0]]
@ -154,7 +154,13 @@ class Plugin:
nick_hits=buf_nicks[0][1]
nick=list(base['nicks'])[buf_nicks[0][0]]
msg=f'{c4}{self.bot.bbs.tailor(title.lower(),50)} {c1}{c3}{self.bot.bbs.tailor(site.lower(),10)} {c1}{c8}{self.bot.bbs.tailor(nick.lower(),10)} {c1}{c7}{str(nick_hits).zfill(2)}{c1}/{c7}{str(hits).zfill(2)} {c6}plays {c1}{c5}?bb {token}'
self.bot.privmsg(target,msg)
top_songs.append(msg)
last_song=""
for song in top_songs:
if song==last_song:
break
last_song=song
self.bot.privmsg(target,song)
#########################################################################################
if command=='old' or command=='all':
# OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD SONGS OLD
@ -319,7 +325,6 @@ class Plugin:
site_youtube=[youtube_title,youtube_site,youtube_user,youtube_userhits,youtube_sitehits,youtube_token,youtube_index]
######################################################################################################################################################################
spotify_top_user_hits=[]
ipdb.set_trace()
for i,_ in enumerate(bbs_data):
if _['site']=='spotify':
spotify_top_user_hits.append(f'{_["hits"]},{i}')

@ -8,7 +8,6 @@ import re
from datetime import datetime, timedelta
import timeago
from irc3.plugins.cron import cron
import ipdb
###########################################################################################
###########################################################################################
D="\x02\x0315"

@ -2,6 +2,58 @@
import os
import irc3
from stat import S_ISFIFO
__doc__ = '''
ds notes
mkdir /run/irc3
chown $USER:$USER /run/irc3
cat whatever > /run/irc3/channelname
#this operates like a typical fifo pipe now
#ratesex_plugin depends on this plugin to operate
==========================================
:mod:`irc3.plugins.fifo` Fifo plugin
==========================================
Allow to cat something to a channel using Unix's fifo
..
>>> from irc3.testing import IrcBot
>>> from irc3.testing import ini2config
>>> import shutil
>>> import os
>>> try:
... shutil.rmtree('/tmp/run/irc3')
... except:
... pass
Usage::
>>> config = ini2config("""
... [bot]
... includes =
... irc3.plugins.fifo
... [irc3.plugins.fifo]
... runpath = /tmp/run/irc3
... """)
>>> bot = IrcBot(**config)
When your bot will join a channel it will create a fifo::
>>> bot.test(':irc3!user@host JOIN #channel')
>>> print(sorted(os.listdir('/tmp/run/irc3')))
[':raw', 'channel']
You'll be able to print stuff to a channel from a shell::
$ cat /etc/passwd > /tmp/run/irc3/channel
You can also send raw irc commands using the ``:raw`` file::
$ echo JOIN \#achannel > /tmp/run/irc3/:raw
'''
@irc3.plugin
class Fifo:
@ -23,7 +75,9 @@ class Fifo:
self.create_fifo(None)
@classmethod
def read_fd(cls, fd):
def read_fd(cls, fd): # pragma: no cover
# this required for python < 3.5
# for more info see https://www.python.org/dev/peps/pep-0475/
while True:
try:
return os.read(fd, cls.BLOCK_SIZE)

@ -11,7 +11,6 @@ from random import randint as rint
from random import choices
dir_path = os.path.dirname(os.path.realpath(__file__))
from glob import glob
import ipdb
###########################################################################################
OPENAPI_KEY = os.environ['OPENAPI_KEY']
###########################################################################################
@ -79,13 +78,11 @@ class Plugin:
######################################################################################
MESSAGE_OK=True
TRAP_OK=True
LOOP_COUNT_LIMIT=1
LOOP_COUNT_LIMIT=5
LOOP_COUNT=0
while MESSAGE_OK:
LOOP_COUNT+=1
print(f'<<< loop: {LOOP_COUNT} >>>')
#this is used to retain chat history context <--- this is used for 'context history'
#prompt_text=f'{self.start_chat_log}\n{term}'
prompt_text=f'{term}'
self.lastterm=f'{term}'
response=openai.Completion.create(
@ -98,12 +95,10 @@ class Plugin:
presence_penalty=self.presence_penalty
)
self.lastresponse=response
# ipdb.set_trace()
##################################################################################
openai_message=response.choices[0].text
USER=mask.nick
MESSAGE=term
# if you use the 'context history' above you may need this code below
# ################################################################################### REPROCESSOR SOF
# # SIMILARITY - QUERY SENT VS QUERY ANSWER
# if MESSAGE_OK:
@ -154,7 +149,6 @@ class Plugin:
if MESSAGE_OK and TRAP_OK:
self.bot.openai_history.push_openai_messages(openai_message)
_msg = re.findall(r'.{1,400}(?:\s+|$)', openai_message)
#this was used to remove any preface glitches where the 1st line would be glitched
#if len(_msg) > 1:
# if len(_msg[0]) < len(_msg[1])//2:
# print(f'openai - discovered and removed a preface glitch: {_msg[0].strip()}')