Compare commits

...

15 Commits

Author SHA1 Message Date
3ffccff799
Woops, fixed URL 2020-02-06 15:32:56 +01:00
521cf77c30
Point to bots repository 2020-02-06 15:32:56 +01:00
mb
6f0dd64061 Update 'README.md' 2019-09-11 22:34:07 +02:00
mb
708283a4cc Update 'README.md' 2019-09-11 22:29:20 +02:00
d6bf65db6f testing the hook :) 2019-07-17 19:01:25 +02:00
ef3a6f2f7c testing the hook :) 2019-07-17 19:00:28 +02:00
e481171c1b testing the hook :) 2019-07-17 18:57:12 +02:00
62ddb363da testing the hook :) 2019-07-17 18:56:29 +02:00
9bc42a9010 testing the hook :) 2019-07-17 18:55:45 +02:00
fe8fddd6fb changing the path of the links to relative links 2019-07-17 18:52:55 +02:00
06046e121b testing the git hook again 2019-07-17 18:47:19 +02:00
a0d7665677 testing the git hook 2019-07-17 18:41:51 +02:00
c68376e373 we fixed the logbot book error in Bucharest 2019-07-17 18:36:06 +02:00
mb
dedfdd114a Update 'README.md' 2019-05-03 13:33:07 +02:00
mb
8e743178f1 Merge branch 'master' of s/logbot into master
super! nice feature
2019-05-03 13:25:03 +02:00
2 changed files with 38 additions and 37 deletions

View File

@ -1,6 +1,8 @@
> note: merged into https://git.vvvvvvaria.org/varia/bots
# logbot # logbot
A small XMPP bot written in Python (using the slixmpp library), that logs all images and messages with the mentioning of *@bot*. A small XMPP bot written in Python (using the slixmpp library) that logs all images and messages with the mentioning of *@bot* to an HTML page, to allow collaborative log writing over time.
To run it: To run it:
@ -8,7 +10,7 @@ To run it:
Dependencies: Dependencies:
$ sudo pip3 install slixmpp $ sudo pip3 install slixmpp beautifulsoup4
--- ---

View File

@ -82,8 +82,8 @@ class MUCBot(slixmpp.ClientXMPP):
f.write(u.read()) # write image to file f.write(u.read()) # write image to file
f.close() # close the output file f.close() # close the output file
# Add image to log # Add the image to the log
img = '<img class="image" src="{}">'.format(msg['oob']['url']) img = '<img class="image" src="{}">'.format(filename)
log = 'log.html' log = 'log.html'
log_path = os.path.join(self.output, log) log_path = os.path.join(self.output, log)
f = open(log_path, 'a+') f = open(log_path, 'a+')
@ -91,7 +91,7 @@ class MUCBot(slixmpp.ClientXMPP):
f.close() f.close()
# Include messages in the log (only when '#publish' is used in the message) # Include messages in the log (only when '@bot' is used in the message)
if '@bot' in msg['body']: if '@bot' in msg['body']:
# reply from the bot # reply from the bot
@ -99,7 +99,7 @@ class MUCBot(slixmpp.ClientXMPP):
mbody="Noted! And added to the log. Thanks {}!".format(msg['mucnick']), mbody="Noted! And added to the log. Thanks {}!".format(msg['mucnick']),
mtype='groupchat') mtype='groupchat')
# Add message to log # Add the message to the log!
message = '<p class="message">{}</p>'.format(msg['body'].replace('@bot','')) message = '<p class="message">{}</p>'.format(msg['body'].replace('@bot',''))
log = 'log.html' log = 'log.html'
log_path = os.path.join(self.output, log) log_path = os.path.join(self.output, log)
@ -107,15 +107,14 @@ class MUCBot(slixmpp.ClientXMPP):
f.write(message+'\n') f.write(message+'\n')
f.close() f.close()
if '/book' in msg['body']: # Check if this is a book if '/book' in msg['body']: # Check if this is a book ...
self.send_message(mto=self.room, self.send_message(mto=self.room,
mbody="Oh a book, that's cool! Thanks {}!".format(msg['mucnick']), mbody="Oh a book, that's cool! Thanks {}!".format(msg['mucnick']),
mtype='groupchat') mtype='groupchat')
# Start of book feature
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import requests
import re import re
book = msg['body'].replace('@bot', '').replace('/book', '') book = msg['body'].replace('@bot', '').replace('/book', '')