User Tools

Site Tools


ircterm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ircterm [2015-01-18 01:41] robircterm [2021-05-21 14:00] (current) simon
Line 1: Line 1:
 +===== Hardware Status =====
 +
 +Normal screen is currently <del>out of action</del> **gubbed**. Tim recommends checking caps however not enough time was available on the day of discovering the screen being out. A temporary screen has been put in place to allow for interim IRC usage.
 +
 ===== Project Background ===== ===== Project Background =====
  
Line 111: Line 115:
 /home/pi/idle.py: /home/pi/idle.py:
 <code> <code>
-#!/usr/bin/python+#!/usr/bin/env python
  
-import logging +import paho.mqtt.client as mqtt 
-import os +import subprocess
-import pika +
-import time+
  
-logging.getLogger('').setLevel(logging.INFO) +last_state = None
-logging.getLogger('pika').setLevel(logging.ERROR)+
  
-amqp_host = "amqp.hacklab" +def on_connect(client, userdata, flags, rc): 
-amqp_exchange = "events" +    client.subscribe("sensor/global/presence")
-topic = "presence.status"+
  
-tvstate = False+def on_message(client, userdata, msg): 
 +    global last_state
  
-connection = pika.BlockingConnection(pika.ConnectionParameters(host=amqp_host)+    # ignore retained (non-realtimemessages 
-channel = connection.channel() +    #if msg.retain: 
-channel.exchange_declare(exchange=amqp_exchange, type="topic")+    #    return
  
-result channel.queue_declare(exclusive=True) +    if last_state !msg.payload: 
-queue_name = result.method.queue +        # state has changed 
-channel.queue_bind(exchange=amqp_exchangequeue=queue_name, routing_key=topic)+        if msg.payload == "active": 
 +            # screen on 
 +            subprocess.call("tvservice -p", shell=True) 
 +        elif msg.payload == "empty": 
 +            # screen off 
 +            subprocess.call("tvservice -o"shell=True) 
 +        last_state = msg.payload
  
-def callback(ch, method, properties, body): +m = mqtt.Client() 
-    global tvstate+m.on_connect = on_connect 
 +m.on_message = on_message 
 +m.connect("mqtt"
 +m.loop_forever() 
 +</code>
  
-    changed = properties.headers['changed'+Required to run:
-    state = properties.headers['state'+
-    old_state = properties.headers.get('old_state', None)+
  
-    if state == 'ACTIVE': +<code> 
-        if tvstate == False: +apt-get install python-pip 
-            os.system("tvservice -p") +pip install paho-mqtt
-            tvstate = True +
-    elif state == 'EMPTY': +
-        os.system("tvservice -o") +
-        tvstate = False +
- +
-channel.basic_consume(callback, +
-                      queue=queue_name, +
-                      no_ack=True) +
-channel.start_consuming()+
 </code> </code>
  
-Required to run:+Log file of TV status (due to people wondering if it doesn't actually ever turn off):
  
 <code> <code>
-apt-get install python-pika+~/idle.log
 </code> </code>
  
Line 166: Line 166:
 Summary: Summary:
  
-  * Auto connect to freenode+  * Auto connect to Libera
   * NickServ identification   * NickServ identification
   * Main channel window with only PUBLICS, ACTIONS and  NICKS.   * Main channel window with only PUBLICS, ACTIONS and  NICKS.
Line 175: Line 175:
 servers = ( servers = (
   {   {
-    address = "irc.freenode.net"; +    address = "irc.libera.chat"; 
-    chatnet = "freenode"; +    chatnet = "libera"; 
-    port = "6667"; +    port = "6697"; 
-    use_ssl = "no"; +    use_ssl = "yes"; 
-    ssl_verify = "no";+    ssl_verify = "yes";
     autoconnect = "yes";     autoconnect = "yes";
   }   }
Line 185: Line 185:
  
 chatnets = { chatnets = {
-  freenode = {+  libera = {
     type = "IRC";     type = "IRC";
     autosendcmd = "/^msg nickserv identify <PASSWORD>;/^win 2";     autosendcmd = "/^msg nickserv identify <PASSWORD>;/^win 2";
Line 194: Line 194:
   { name = "#irssi"; chatnet = "ircnet"; autojoin = "No"; },   { name = "#irssi"; chatnet = "ircnet"; autojoin = "No"; },
   { name = "silc"; chatnet = "silc"; autojoin = "No"; },   { name = "silc"; chatnet = "silc"; autojoin = "No"; },
-  { name = "#edinhacklab"; chatnet = "freenode"; autojoin = "yes"; }+  { name = "#edinhacklab"; chatnet = "libera"; autojoin = "yes"; }
 ); );
  
Line 392: Line 392:
         chat_type = "IRC";         chat_type = "IRC";
         name = "#edinhacklab";         name = "#edinhacklab";
-        tag = "freenode";+        tag = "libera";
       }       }
     );     );
Line 411: Line 411:
  
   * /srv/hacksense/bin/request-soundfile   * /srv/hacksense/bin/request-soundfile
-  * /srv/hacksense/lib/hacksense.py 
- 
-The following was required for hacksense.py but has been suggested by Tim that any Redis stuff should be removed from hacksense.py instead. 
- 
-<code> 
-apt-get install python-redis 
-</code> 
  
   * uhoh.mp3 is on doorbot which has the speaker attached to it.   * uhoh.mp3 is on doorbot which has the speaker attached to it.
  
 In irssi config: beep_cmd = "/srv/hacksense/bin/request-soundfile uhoh.mp3 &" In irssi config: beep_cmd = "/srv/hacksense/bin/request-soundfile uhoh.mp3 &"
ircterm.1421545272.txt.gz · Last modified: 2015-10-05 15:55 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki