Bootleg bot: Difference between revisions

From XPUB & Lens-Based wiki
 
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Networks==
''This page is prepared for the prototyping class on 3 March 2026 as part of SI29 and follows a Special Issue day with Doriane and Simon fully on topic of [[The bootleg library]].''


(we will go through the following commands from '''sergio''')
https://git.xpub.nl/kamo/bot-magic-words


To which networks is sergio connected right now?


ip a
==the zulip bot==


To which networks is the bootleg library connected right now?
First install the requirements listed on this page:


eh... we don't know if we can't ssh in?
https://zulip.com/help/writing-bots


Are we sharing a network with the bootleg library?
You can run the bot with:


  yes! the HUB
  zulip-run-bot --config-file bootlegbot.zuliprc bootlegbot.py


Can we check if we can communicate with the bootleg library through this network? (see all HUB ip address [[HUB|here]])
(or <code>uv run zulip-run-bot --config-file bootlegbot.zuliprc bootlegbot.py</code> if you are using uv)


ping 10.0.0.103
===bootlegbot.py===


Who else is on the network right now?
<syntaxhighlight lang="python">
class BootlegBot(object):
    '''
    This is a small zulip bot to interact with the 👢🦵 library
    '''


nmap 10.0.0.*
    def usage(self):
        return '''Ask the bot about a book and they will search for it in the 👢🦵 library'''


And who else is on the eduroam right now? (in the same subnet)
    def handle_message(self, message, bot_handler):
        # This happens when someone write to the bot


nmap 145.24.152.*
        sender = message['sender_full_name']
        content = message['content']
        print(f'{sender} wrote to the bot: "{content}"')


We can make such a mapping because we are part of the same LAN network.
handler_class = BootlegBot
</syntaxhighlight>


(LAN = local area network)
===bootlegbot.zuliprc===


But how do you travel from one network to another within the WAN?
<pre>
[api]
email=bootleg-bot@zulip.xpub.nl
key=XXXXXXXX
site=https://zulip.xpub.nl
</pre>


(WAN = wider area network, aka the internet)
We need to share the key with each other somehow.


traceroute zulip.xpub.nl
===Zulip bot API===


But how do we reach the hidden LAN/VPN 10.0.0.* network from the WAN?
https://zulip.com/help/interactive-bots-api


ssh tunnelling!
==hello Python!==


==SSH tunnels==
see: [[Hello Python]]


https://ittavern.com/visual-guide-to-ssh-tunneling-and-port-forwarding/
==SSH to bootleg library==
 
There are two ways in which we can do this.
 
===laptop > sergio > bootleg library (from outside the school)===
 
ssh sergio
sudo su - xpub
ssh pi@10.0.0.103
 
===laptop > bootleg library (on eduroam)===
ssh pi@145.24.153.55
 
==read database==
 
* Simon and Luke made this Python script in 2021, to make the temporary index cards: https://git.vvvvvvaria.org/simoon/temporary-indexing
* documentation of sqlite module in Python: https://docs.python.org/3/library/sqlite3.html
 
==write to database==
 
* a standalone webform for file uploads
* using the bootleg library upload URLs
* hosted on sergio (but can be hosted on another sandbox too in the future)
 
==See also==
 
* [[The bootleg library]] main documentation page of the bootleg library project
* https://cc.practices.tools/etherdot/bootleg-library/ graph based story of the bootleg library project
 
[[Category:Workbooks]]

Latest revision as of 11:20, 24 March 2026

This page is prepared for the prototyping class on 3 March 2026 as part of SI29 and follows a Special Issue day with Doriane and Simon fully on topic of The bootleg library.

https://git.xpub.nl/kamo/bot-magic-words


the zulip bot

First install the requirements listed on this page:

https://zulip.com/help/writing-bots

You can run the bot with:

zulip-run-bot --config-file bootlegbot.zuliprc bootlegbot.py

(or uv run zulip-run-bot --config-file bootlegbot.zuliprc bootlegbot.py if you are using uv)

bootlegbot.py

class BootlegBot(object):
    '''
    This is a small zulip bot to interact with the 👢🦵 library
    '''

    def usage(self):
        return '''Ask the bot about a book and they will search for it in the 👢🦵 library'''

    def handle_message(self, message, bot_handler):
        # This happens when someone write to the bot

        sender = message['sender_full_name']
        content = message['content']
        print(f'{sender} wrote to the bot: "{content}"')

handler_class = BootlegBot

bootlegbot.zuliprc

[api]
email=bootleg-bot@zulip.xpub.nl
key=XXXXXXXX
site=https://zulip.xpub.nl

We need to share the key with each other somehow.

Zulip bot API

https://zulip.com/help/interactive-bots-api

hello Python!

see: Hello Python

SSH to bootleg library

There are two ways in which we can do this.

laptop > sergio > bootleg library (from outside the school)

ssh sergio
sudo su - xpub
ssh pi@10.0.0.103

laptop > bootleg library (on eduroam)

ssh pi@145.24.153.55

read database

write to database

  • a standalone webform for file uploads
  • using the bootleg library upload URLs
  • hosted on sergio (but can be hosted on another sandbox too in the future)

See also