')
- with open(css_path, 'w') as c:
- c.write(css_template)
- with open(used_handles_path, 'w') as h:
- h.write('-----')
-
- # add entry to log
+ # save entry
handle = request_handle(used_handles_path)
- print(f'Picked a handle: { handle }')
- now = datetime.now().strftime('%A %d %B (%Y)')
- print(f'Now is: { now }')
- post = f'''
- { handle }
- { entry }
- Added on { now }
-
'''
- print(f'Post: { post }')
- with open(log_path, 'a+') as l:
- l.write(post)
- print('added to the log!')
+ newfile_path = output + '/entries/' + handle + '.txt'
+ with open(newfile_path, 'w') as f:
+ f.write(entry)
with open(used_handles_path, 'a+') as h:
h.write(handle)
- print('added to the .handles file!')
+
+ print('Saved!')
+
+def delete(self, handle):
+ used_handles = '.handles.txt'
+ used_handles_path = os.path.join(self.output, used_handles)
+
+ possible_file_paths = [
+ os.path.join(self.output, 'entries', handle + '.txt'),
+ os.path.join(self.output, 'entries', handle + '.png'),
+ os.path.join(self.output, 'entries', handle + '.jpg')
+ ]
+ for path in possible_file_paths:
+ if os.path.isfile(path):
+ cmd = f'rm { path }'
+ print(f'> { cmd }')
+ os.system(cmd)
+ print(f'Removed { path }.')
+ pass
+
+ # delete handle from .handles.txt file
+ # read
+ with open(used_handles_path, 'r') as h:
+ txt = h.read()
+ txt = txt.replace(handle+'\n', "")
+ # write
+ with open(used_handles_path, 'w') as h:
+ h.write(txt)
+
+
+# def write_to_log(self, entry):
+# output = self.output
+# # print(f'Output: { output }')
+# log = 'index.html'
+# css = 'stylesheet.css'
+# used_handles = '.handles.txt'
+# log_path = os.path.join(output, log)
+# css_path = os.path.join(output, css)
+# used_handles_path = os.path.join(output, used_handles)
+
+# # check if file exists, if not: write it!
+# if not os.path.isfile(log_path):
+# html_template = open('templates/index.html', 'r').read()
+# css_template = open('templates/stylesheet.css', 'r').read()
+# with open(log_path, 'w') as l:
+# l.write(html_template)
+# l.write(f'
{ self.groupchat }
')
+# with open(css_path, 'w') as c:
+# c.write(css_template)
+# with open(used_handles_path, 'w') as h:
+# h.write('-----')
+
+# # add entry to log
+# handle = request_handle(used_handles_path)
+# print(f'Picked a handle: { handle }')
+# now = datetime.now().strftime('%A %d %B (%Y)')
+# print(f'Now is: { now }')
+# post = f'''
+# { handle }
+# { entry }
+# Added on { now }
+#
'''
+# print(f'Post: { post }')
+# with open(log_path, 'a+') as l:
+# l.write(post)
+# print('added to the log!')
+# with open(used_handles_path, 'a+') as h:
+# h.write(handle)
+# print('added to the .handles file!')
# *spark
# add annotations
@@ -119,12 +161,13 @@ class MUCBot(slixmpp.ClientXMPP):
and messages that are marked with @bot to a folder.
"""
- def __init__(self, use, password, groupchat, nickname, output):
+ def __init__(self, use, password, groupchat, nickname, output, mode):
slixmpp.ClientXMPP.__init__(self, use, password)
self.groupchat = groupchat
self.nick = nickname
self.output = output
+ self.mode = mode
# The session_start event will be triggered when
# the bot establishes its connection with the server
@@ -179,6 +222,9 @@ PS. you can access these logs at https://vvvvvvaria.org/logs/.''',
# Check if output folder exists
if not os.path.exists(self.output):
os.mkdir(self.output)
+ os.mkdir(self.output + '/entries/')
+ with open(os.path.join(self.output, '.handles.txt'), 'w') as f:
+ pass
# Check if an OOB URL is included in the stanza (which is how an image is sent)
# (OOB object - https://xmpp.org/extensions/xep-0066.html#x-oob)
@@ -210,23 +256,34 @@ PS. you can access these logs at https://vvvvvvaria.org/logs/.''',
mbody=f'Noted! And added to the log. Thanks { msg["mucnick"] }!',
mtype='groupchat')
- # Add the message to the log!
- message = msg['body'].replace('__ADD__','')
- message = f'
{ message }
'
- write_to_log(self, message)
+ # Record the entry
+ rec(self, msg['body'])
- # Include a new post in the log (only when '__ADD__' is used in the message)
- if '__ANNOTATE__' in msg['body']:
+ # Delete a post from the log
+ if '__DELETE__' in msg['body']:
- handle = msg['body'].split()[1]
- annotation = msg['body'].replace('__ANNOTATE__', '').replace(handle, '')
- post = find_in_soup(self, handle, annotation)
+ handle = re.findall("[aioeu][aioeu][aioeu][aioeu][aioeu]", msg['body'])[0]
# reply from the bot
self.send_message(mto=self.groupchat,
- mbody="Thanks!",
+ mbody=f'Noted! The following post is deleted from the log: { handle }',
mtype='groupchat')
+ # Delete the entry
+ delete(self, handle)
+
+ # Include a new post in the log (only when '__ADD__' is used in the message)
+ # if '__ANNOTATE__' in msg['body']:
+
+ # handle = msg['body'].split()[1]
+ # annotation = msg['body'].replace('__ANNOTATE__', '').replace(handle, '')
+ # post = find_in_soup(self, handle, annotation)
+
+ # # reply from the bot
+ # self.send_message(mto=self.groupchat,
+ # mbody="Thanks!",
+ # mtype='groupchat')
+
# Check if this is a book ...
if '__BOOK__' in msg['body']:
@@ -270,6 +327,16 @@ PS. you can access these logs at https://vvvvvvaria.org/logs/.''',
self.send_message(mto=self.groupchat, mbody='Sorry, no book found!', mtype='groupchat')
+ # Generate HTML logfiles
+ # By default: log
+ if self.mode:
+ mode = str(self.mode.lower().strip())
+ if mode == "log":
+ print('> log.py')
+ elif mode == "stream":
+ print('> stream.py')
+ elif mode == "distribusi":
+ print('> distribusi.py')
if __name__ == '__main__':
# Setup the command line arguments.
@@ -295,6 +362,9 @@ if __name__ == '__main__':
parser.add_argument("-o", "--output", dest="output",
help="output folder, this is where the files are stored",
type=str)
+ parser.add_argument("-m", "--mode", dest="mode",
+ help="logmode, options include: log, stream, distribusi",
+ type=str, default='log')
args = parser.parse_args()
@@ -316,7 +386,7 @@ if __name__ == '__main__':
# Setup the MUCBot and register plugins. Note that while plugins may
# have interdependencies, the order in which you register them does
# not matter.
- xmpp = MUCBot(args.use, args.password, args.groupchat, args.nickname, args.output)
+ xmpp = MUCBot(args.use, args.password, args.groupchat, args.nickname, args.output, args.mode)
xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0045') # Multi-User Chat
xmpp.register_plugin('xep_0199') # XMPP Ping
diff --git a/RECbot/distribusi/distribusi.py b/RECbot/distribusi/distribusi.py
new file mode 100644
index 0000000..9d82595
--- /dev/null
+++ b/RECbot/distribusi/distribusi.py
@@ -0,0 +1,2 @@
+soon :) still thinking how to "insert" distribusi here,
+or make it a dependency
diff --git a/RECbot/example/.handles.txt b/RECbot/example/.handles.txt
new file mode 100644
index 0000000..72b9099
--- /dev/null
+++ b/RECbot/example/.handles.txt
@@ -0,0 +1 @@
+ieiauieiauiiuioiiuioooooeooooeieoooieooouuaiauuaia
\ No newline at end of file
diff --git a/RECbot/example/Screenshot from 2021-01-11 22-58-22.png b/RECbot/example/Screenshot from 2021-01-11 22-58-22.png
new file mode 100644
index 0000000..bbff26b
Binary files /dev/null and b/RECbot/example/Screenshot from 2021-01-11 22-58-22.png differ
diff --git a/RECbot/example/entries/ieooo.txt b/RECbot/example/entries/ieooo.txt
new file mode 100644
index 0000000..0c2327e
--- /dev/null
+++ b/RECbot/example/entries/ieooo.txt
@@ -0,0 +1 @@
+text msg, image, video, audio
diff --git a/RECbot/example/entries/soviet-80s-computers-EFcZsx0VUAAZZoC.jpeg b/RECbot/example/entries/soviet-80s-computers-EFcZsx0VUAAZZoC.jpeg
new file mode 100644
index 0000000..0638195
Binary files /dev/null and b/RECbot/example/entries/soviet-80s-computers-EFcZsx0VUAAZZoC.jpeg differ
diff --git a/RECbot/example/index.html b/RECbot/example/index.html
new file mode 100644
index 0000000..ea1eec1
--- /dev/null
+++ b/RECbot/example/index.html
@@ -0,0 +1,65 @@
+
+
+
+
+ Log
+
+
+
+
+
Welcome to this Log!
+
This Log file is based on chat messages exchanged in a XMPP groupchat and is written by RECbot.
+
+
For the writers of this log, you can:
+
+
+ send an image,
+
+
+ __ADD__ a message,
+
+
+ __DELETE__ it by using the HANDLE on the left (*spark),
+
+
+
+
+
+
+
+
+ Request information about a __BOOK__ by sending a TITLE (*spark, almost there),
+
+
+ ... (*spark)
+
+
+
+
+
ibugev@muc.vvvvvvaria.org
+
+
+ ieooo
+ In general terms, “transhackfeminism” refers to hacking_with_care, using hacking with a meaning of (active) resistance and transformation to generate transversal knowledge through transdisciplinary artistic, aesthetic or cultural practices/ proposals. To work on producing knowledge collectively: without differentiating between theory and practice; as well as to embrace, protect and advance in free culture. To create communities where people meet, exchange, experience and share knowledge. To work on human and non-human alliances and solidarity through DIY/DIWO/DIT biotechnology, artistic and cultural practices.
+
+ To stay in touch with the material-affective dimensions of doing and engaging (bio)practices.
+
+ https://syllabus.pirate.care/topic/transhackfeminism/
+ Added on 11 January 2021
+
+
+ auiio
+
+ Added on 12 January 2021
+
+
+
+
\ No newline at end of file
diff --git a/RECbot/templates/stylesheet.css b/RECbot/example/stylesheet.css
similarity index 100%
rename from RECbot/templates/stylesheet.css
rename to RECbot/example/stylesheet.css
diff --git a/RECbot/generate_handles.py b/RECbot/generate_handles.py
index c45dd94..fa47dd7 100644
--- a/RECbot/generate_handles.py
+++ b/RECbot/generate_handles.py
@@ -1,14 +1,16 @@
import random
-characters = ['*','+','-','/','-','-']
+# characters = ['*','+','-','/','-','-']
+characters = ['a','e','o','i','u']
out = open('handles.txt', 'w')
handles = set()
# generate handles
-while len(handles) < 1000:
+while len(handles) < 2500:
handle = ''
for h in range(5):
handle += random.choice(characters)
+ print(handle)
handles.add(handle)
# write handles to file
diff --git a/RECbot/log/log.py b/RECbot/log/log.py
new file mode 100644
index 0000000..081da82
--- /dev/null
+++ b/RECbot/log/log.py
@@ -0,0 +1,15 @@
+import os
+from jinja2 import Template
+
+def generate_log_page(input, output):
+ files = os.listdir(input)
+
+ template = Template(open('./log/templates/index.html').read())
+ html = template.render(entries=files)
+ print(html)
+ logfile = os.path.join(output, 'index.html')
+ with open(logfile, 'w') as log:
+ log.write(html)
+
+if __name__ == "__main__":
+ generate_log_page('./testing/entries/', './testing/')
\ No newline at end of file
diff --git a/RECbot/templates/index.html b/RECbot/log/templates/index.html
similarity index 92%
rename from RECbot/templates/index.html
rename to RECbot/log/templates/index.html
index b609caa..a0d77cb 100644
--- a/RECbot/templates/index.html
+++ b/RECbot/log/templates/index.html
@@ -44,4 +44,9 @@
-->
-
+