forked from varia/bots
updating readme, bot and template files
This commit is contained in:
parent
bbe7b83dfa
commit
662eb5645d
@ -16,13 +16,13 @@ The bot is used in group chats, where it includes all images that are send to th
|
|||||||
|
|
||||||
* check if `RECbot` is one of the participants in the groupchat!
|
* check if `RECbot` is one of the participants in the groupchat!
|
||||||
* send an image to the groupchat **OR** use one of the `__ACTION WORDS__` below
|
* send an image to the groupchat **OR** use one of the `__ACTION WORDS__` below
|
||||||
* the bot replies and thanks you kindly
|
* the bot confirms your contribution and writes the message to a file
|
||||||
* check the output of RECbot (locally or online, for example: <https://vvvvvvaria.org/logs>)
|
* check the output of RECbot (locally or online, for example: <https://vvvvvvaria.org/logs>)
|
||||||
|
|
||||||
RECbot works with `__ACTION WORDS__` and unique `:HANDLES`.
|
RECbot works with `__ACTION WORDS__` and unique `<HANDLE>` codes.
|
||||||
|
|
||||||
* `__ADD__` RECbot entries with `__ADD__ <message>`, for example: `__ADD__ Logging as a form of stretching time.` or `__ADD__ https://nicelink.org`
|
* `__ADD__` RECbot entries with `__ADD__ <message>`, for example: `__ADD__ Logging as a form of stretching time.` or `__ADD__ https://nicelink.org`
|
||||||
* `__DELETE__` RECbot entries with `__DELETE__ :HANDLE`, for example: `__DELETE__ :~+*/+-` (\*spark)
|
* `__DELETE__` RECbot entries with `__DELETE__ <HANDLE>`, for example: `__DELETE__ ~+*/+-` (\*spark)
|
||||||
* `__BOOK__` (\*sparks)
|
* `__BOOK__` (\*sparks)
|
||||||
|
|
||||||
## Install RECbot
|
## Install RECbot
|
||||||
@ -76,9 +76,22 @@ These modes can be changed at any moment.
|
|||||||
|
|
||||||
[\*] These are standalone scripts. They can be used on any set of files in a folder and generate HTML pages with customizable styling.
|
[\*] These are standalone scripts. They can be used on any set of files in a folder and generate HTML pages with customizable styling.
|
||||||
|
|
||||||
|
```
|
||||||
|
RECbot <modes> <log HTML page>
|
||||||
|
|
||||||
|
│ --distribusi > distribusi.py
|
||||||
|
│ [output folder] --log > log.py [output_folder/index.html]
|
||||||
|
│ (saved as files) --stream > stream.py (saved as index.html + stylesheet.css)
|
||||||
|
│ --xxx > xxx.py
|
||||||
|
│
|
||||||
|
└── stores text/media
|
||||||
|
files in output folder
|
||||||
|
(local/server)
|
||||||
|
```
|
||||||
|
|
||||||
------------
|
------------
|
||||||
|
|
||||||
How can `__ACTION WORDS__` become `__MAGIC WORDS__` ???
|
How can `__ACTION WORDS__` become magical `__MAGIC WORDS__` ???
|
||||||
|
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ def write_to_log(self, entry):
|
|||||||
|
|
||||||
# check if file exists, if not: write it!
|
# check if file exists, if not: write it!
|
||||||
if not os.path.isfile(log_path):
|
if not os.path.isfile(log_path):
|
||||||
html_template = open('templates/log.html', 'r').read()
|
html_template = open('templates/index.html', 'r').read()
|
||||||
css_template = open('templates/stylesheet.css', 'r').read()
|
css_template = open('templates/stylesheet.css', 'r').read()
|
||||||
with open(log_path, 'w') as l:
|
with open(log_path, 'w') as l:
|
||||||
l.write(html_template)
|
l.write(html_template)
|
||||||
@ -71,7 +71,6 @@ def write_to_log(self, entry):
|
|||||||
<small class="postid">{ handle }</small>
|
<small class="postid">{ handle }</small>
|
||||||
{ entry }
|
{ entry }
|
||||||
<small class="date">Added on { now }</small>
|
<small class="date">Added on { now }</small>
|
||||||
<small class="tags">Tags:<span class="tagcontainer"></span></small>
|
|
||||||
</div>'''
|
</div>'''
|
||||||
print(f'Post: { post }')
|
print(f'Post: { post }')
|
||||||
with open(log_path, 'a+') as l:
|
with open(log_path, 'a+') as l:
|
||||||
@ -81,34 +80,37 @@ def write_to_log(self, entry):
|
|||||||
h.write(handle)
|
h.write(handle)
|
||||||
print('added to the .handles file!')
|
print('added to the .handles file!')
|
||||||
|
|
||||||
def find_in_soup(self, handle, tag):
|
# *spark
|
||||||
print('--------ADD TAG ---------')
|
# add annotations
|
||||||
print(f'handle: { handle }')
|
|
||||||
log = 'index.html'
|
|
||||||
log_path = os.path.join(self.output, log)
|
|
||||||
html = open(log_path, 'r').read()
|
|
||||||
soup = BeautifulSoup(html, 'html.parser')
|
|
||||||
# print(soup.prettify())
|
|
||||||
post = soup.find(id=handle)
|
|
||||||
# print(f'posts: { posts }')
|
|
||||||
# for post in posts:
|
|
||||||
print(f'post: { post }')
|
|
||||||
if post:
|
|
||||||
# tagcontainer = post.findChildren(id="tagcontainer", recursive=True)[0]
|
|
||||||
# print(f'tagcontainer: { tagcontainer }')
|
|
||||||
# print(f'tagcontainer.contents: { tagcontainer.contents }')
|
|
||||||
# tagcontainer.contents.append(f'<span class="tag">{ tag }</span>')
|
|
||||||
# print(f'tagcontainer.contents: { tagcontainer.contents }')
|
|
||||||
|
|
||||||
# new_tag = soup.new_tag("a", href="http://www.example.com")
|
# def find_in_soup(self, handle, annotation):
|
||||||
new_tag = soup.new_tag("span")
|
# print('--------ADD ANNOTATION ---------')
|
||||||
new_tag.append(tag)
|
# print(f'handle: { handle }')
|
||||||
soup.find(id=handle).find(class_="tagcontainer").append(new_tag)
|
# log = 'index.html'
|
||||||
print(f'new soup: { str(soup) } ')
|
# log_path = os.path.join(self.output, log)
|
||||||
|
# html = open(log_path, 'r').read()
|
||||||
|
# soup = BeautifulSoup(html, 'html.parser')
|
||||||
|
# # print(soup.prettify())
|
||||||
|
# post = soup.find(id=handle)
|
||||||
|
# # print(f'posts: { posts }')
|
||||||
|
# # for post in posts:
|
||||||
|
# print(f'post: { post }')
|
||||||
|
# if post:
|
||||||
|
# # annotationcontainer = post.findChildren(id="annotationcontainer", recursive=True)[0]
|
||||||
|
# # print(f'annotationcontainer: { annotationcontainer }')
|
||||||
|
# # print(f'annotationcontainer.contents: { annotationcontainer.contents }')
|
||||||
|
# # annotationcontainer.contents.append(f'<span class="annotation">{ annotation }</span>')
|
||||||
|
# # print(f'annotationcontainer.contents: { annotationcontainer.contents }')
|
||||||
|
|
||||||
# write soup to file
|
# # new_annotation = soup.new_annotation("a", href="http://www.example.com")
|
||||||
with open(log_path, 'w') as l:
|
# new_annotation = soup.new_annotation("span")
|
||||||
l.write(str(soup))
|
# new_annotation.append(annotation)
|
||||||
|
# soup.find(id=handle).find(class_="annotationcontainer").append(new_annotation)
|
||||||
|
# print(f'new soup: { str(soup) } ')
|
||||||
|
|
||||||
|
# # write soup to file
|
||||||
|
# with open(log_path, 'w') as l:
|
||||||
|
# l.write(str(soup))
|
||||||
|
|
||||||
|
|
||||||
class MUCBot(slixmpp.ClientXMPP):
|
class MUCBot(slixmpp.ClientXMPP):
|
||||||
@ -148,10 +150,6 @@ class MUCBot(slixmpp.ClientXMPP):
|
|||||||
# password=the_room_password,
|
# password=the_room_password,
|
||||||
wait=True)
|
wait=True)
|
||||||
|
|
||||||
# NOTE(luke): disabled for now. We'll make it possible to speak to logbot privately later
|
|
||||||
# Send a message to the room
|
|
||||||
# self.send_message(mto=self.groupchat, mbody='Hello! RECbot here. I\'m new :). You can log text/image/sound/video messages, by including @bot in your message. Happy logging! PS. you can access the logs at https://vvvvvvaria.org/logs/', mtype='groupchat')
|
|
||||||
|
|
||||||
def muc_message(self, msg):
|
def muc_message(self, msg):
|
||||||
# Some inspection commands
|
# Some inspection commands
|
||||||
#print('Message: {}'.format(msg))
|
#print('Message: {}'.format(msg))
|
||||||
@ -159,6 +157,25 @@ class MUCBot(slixmpp.ClientXMPP):
|
|||||||
# Always check that a message is not the bot itself, otherwise you will create an infinite loop responding to your own messages.
|
# Always check that a message is not the bot itself, otherwise you will create an infinite loop responding to your own messages.
|
||||||
if msg['mucnick'] != self.nick:
|
if msg['mucnick'] != self.nick:
|
||||||
|
|
||||||
|
if '@bot' in msg['body']:
|
||||||
|
# Send some info about this bot.
|
||||||
|
self.send_message(
|
||||||
|
mto=self.groupchat,
|
||||||
|
mbody='''Hello! RECbot here. I\'m a new version of logbot.
|
||||||
|
|
||||||
|
You can log type of text messages, by including __ADD__ in your message. Or, you can send an image/sound(*spark)/video(*spark) file to this chat and it will be logged for you.
|
||||||
|
|
||||||
|
Items in the log can also be deleted again, by using the unique HANDLE of each post. You can find these handles in the generated HTML page, they look like this: +//-*.
|
||||||
|
|
||||||
|
Happy logging!
|
||||||
|
|
||||||
|
PS. you can access these logs at https://vvvvvvaria.org/logs/.''',
|
||||||
|
mtype='groupchat'
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Respond to incoming __ACTION_WORDS__!
|
||||||
|
|
||||||
# Check if output folder exists
|
# Check if output folder exists
|
||||||
if not os.path.exists(self.output):
|
if not os.path.exists(self.output):
|
||||||
os.mkdir(self.output)
|
os.mkdir(self.output)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="welcome">
|
<div id="welcome">
|
||||||
<p>Welcome to this Log!</p>
|
<p>Welcome to this Log!</p>
|
||||||
<p>This Log file is written through <em>logbot</em> and chat messages exchanged in a <em>XMPP groupchat</em>.</p>
|
<p>This Log file is based on chat messages exchanged in a <em>XMPP groupchat</em> and is written by <em>RECbot</em>.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>For the writers of this log, you can:
|
<p>For the writers of this log, you can:
|
||||||
<br>
|
<br>
|
||||||
@ -19,19 +19,19 @@
|
|||||||
<code>__ADD__</code> a message,
|
<code>__ADD__</code> a message,
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<code>__DELETE__</code> it by using the <code>~HANDLE</code> on the left (*spark),
|
<code>__DELETE__</code> it by using the <code>HANDLE</code> on the left (*spark),
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<code>__ANNOTATE__</code> something using the <code>~HANDLE</code>,
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
<!-- <code>__ANNOTATE__</code> something using the <code>~HANDLE</code>, -->
|
||||||
|
<!-- <br> -->
|
||||||
|
<!-- <br> -->
|
||||||
<!-- <code>__ECHO__</code> material using the <code>~HANDLE</code> or a <code>#TAG</code> (*spark), -->
|
<!-- <code>__ECHO__</code> material using the <code>~HANDLE</code> or a <code>#TAG</code> (*spark), -->
|
||||||
<!-- <br> -->
|
<!-- <br> -->
|
||||||
<!-- <br> -->
|
<!-- <br> -->
|
||||||
<code>__BOOK__</code> (*spark, almost there),
|
Request information about a <code>__BOOK__</code> by sending a <code>TITLE</code> (*spark, almost there),
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
or, ... (*spark)
|
... (*spark)
|
||||||
</p>
|
</p>
|
||||||
<!-- <hr> -->
|
<!-- <hr> -->
|
||||||
</div>
|
</div>
|
||||||
|
@ -17,7 +17,8 @@ div#welcome{
|
|||||||
padding:0;
|
padding:0;
|
||||||
}
|
}
|
||||||
div#welcome hr{
|
div#welcome hr{
|
||||||
border:1px dotted blue;
|
border:0;
|
||||||
|
border-bottom:1px dotted blue;
|
||||||
margin:2em 0;
|
margin:2em 0;
|
||||||
}
|
}
|
||||||
div#echo{
|
div#echo{
|
||||||
|
Loading…
Reference in New Issue
Block a user