mirror of
https://github.com/fotoente/MIsskey-ebooks-bot
synced 2024-11-13 23:27:10 +00:00
Adjustement to Mi.py 3.2.X
This commit is contained in:
parent
181e844a8e
commit
8cd5c3e834
3 changed files with 16 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
|||
# MIsskey-ebooks-bot
|
||||
Misskey eBooks Bot with Markov Chain
|
||||
|
||||
[Example @roboduck@ente.fun](https://ente.fun/@roboduck)
|
||||
|
||||
### Introduction
|
||||
|
@ -9,7 +10,7 @@ It can only read and write from and to Misskey. Reading from Mastodon or Pleroma
|
|||
It posts every hour on his own and reacts to mentions. Every 12 hours the bot reloads the notes and recalculates the Markov Chain.
|
||||
|
||||
### Installation
|
||||
To run `mi.py` you must isntall `python3.9` and `python3.9-dev` onto your system.
|
||||
To run `mi.py` you must isntall `python3.9` and `python3.9-dev` onto your system. (Please be aware of the requirements for mi.py!)
|
||||
`mi.py` is still under development and a lot of things change there quickly so please be aware that there could be chances that something changed, that I haven't implemented in the bot at the moment.
|
||||
to install `mi.py`please use the following command.
|
||||
`pip install git+https://github.com/yupix/Mi.py.git`
|
||||
|
@ -51,7 +52,7 @@ Just to test it you can use `nohup python3.9 rdbot.py &` in the directory the bo
|
|||
|
||||
### Known Quirks
|
||||
- The startup needs quite some time. On my system about 10 seconds. You knwo that everything runs well when the first Note is posted.
|
||||
- When the bot is started, it could happen that he runs in a timeout in the first 60 seconds. To prevent that, just mention the bot and he will stay in a loop
|
||||
- When a DM is sent to the bot he exits completly. There is a missing subroutine, who will be fixed in a later version of the framework
|
||||
- When the bot is started, it could happen that he runs in a timeout in the first 60 seconds. To prevent that, just mention the bot and he will stay in a loop.
|
||||
- If a lot of notes are loaded, the bot sometimes get stuck. To work around this don't use more than 5.000 notes to load.
|
||||
|
||||
## Works on my machine!
|
||||
|
|
2
rdbot.py
2
rdbot.py
|
@ -70,5 +70,5 @@ class MyBot(commands.Bot):
|
|||
|
||||
if __name__ == "__main__":
|
||||
bot = MyBot()
|
||||
asyncio.run(bot.start(uri, token))
|
||||
asyncio.run(bot.start(uri, token, timeout=600))
|
||||
|
18
roboduck.py
18
roboduck.py
|
@ -22,7 +22,7 @@ def read_posts():
|
|||
#Load configuration
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(os.path.dirname(__file__), 'bot.cfg'))
|
||||
print(os.path.join(os.path.dirname(__file__), 'bot.cfg'))
|
||||
#print(os.path.join(os.path.dirname(__file__), 'bot.cfg'))
|
||||
|
||||
url="https://"+config.get("misskey","instance_read")+"/api/users/show"
|
||||
|
||||
|
@ -90,13 +90,15 @@ def read_posts():
|
|||
textDict = jsonObj
|
||||
textList.append(textDict)
|
||||
|
||||
|
||||
print (i)
|
||||
oldnote = noteid
|
||||
|
||||
|
||||
|
||||
for item in textList:
|
||||
content = str(item["text"])+"\n" #Gets the text item of every JSON element
|
||||
|
||||
if content is None: #Skips empty notes (I don't know how there could be empty notes)
|
||||
continue
|
||||
|
||||
content = re.sub(r"@([a-zA-Z0-9-]*(\.))*[a-zA-Z0-9-]*\.[a-zA-z]*", '', content) #Remove instance name with regular expression
|
||||
content = content.replace("::",": :") #Break long emoji chains
|
||||
text += content.replace("@", "@"+chr(8203))
|
||||
|
@ -107,10 +109,12 @@ def read_posts():
|
|||
|
||||
|
||||
def create_post(text_model):
|
||||
note=""
|
||||
|
||||
#Reading config file bot.cfg with config parser
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(os.path.dirname(__file__), 'bot.cfg'))
|
||||
print(os.path.join(os.path.dirname(__file__), 'bot.cfg'))
|
||||
#print(os.path.join(os.path.dirname(__file__), 'bot.cfg'))
|
||||
|
||||
#Read & Sanitize Inputs
|
||||
try:
|
||||
|
@ -152,7 +156,7 @@ def create_post(text_model):
|
|||
|
||||
if (max_words is not None and min_words is not None):
|
||||
if (min_words >= max_words):
|
||||
print("min_words ("+str(min_words)+") bigger than max_words ("+str(max_words)+")! Swapping values!")
|
||||
#print("min_words ("+str(min_words)+") bigger than max_words ("+str(max_words)+")! Swapping values!")
|
||||
swap = min_words
|
||||
min_words = max_words
|
||||
max_words = swap
|
||||
|
@ -175,7 +179,6 @@ def create_post(text_model):
|
|||
print("min_words: " + str(min_words))
|
||||
"""
|
||||
|
||||
|
||||
#Applying Inputs
|
||||
note = text_model.make_sentence(
|
||||
test_output = test_output,
|
||||
|
@ -185,4 +188,5 @@ def create_post(text_model):
|
|||
max_words = max_words,
|
||||
min_words = min_words
|
||||
)
|
||||
|
||||
return note
|
Loading…
Reference in a new issue