mcevent.py
changeset 13 4db51cfb9e15
parent 12 5f16a0f3124c
child 14 02d532e70dfb
equal deleted inserted replaced
12:5f16a0f3124c 13:4db51cfb9e15
    10 """
    10 """
    11 This script reads mcabber event lines from the standard input
    11 This script reads mcabber event lines from the standard input
    12 and creates events accordingly.  Examples:
    12 and creates events accordingly.  Examples:
    13 STATUS O user2@domain.org
    13 STATUS O user2@domain.org
    14 MSG IN user@domain.org
    14 MSG IN user@domain.org
    15 UNREAD 1
    15 UNREAD 1 0 1 0
    16 """
    16 """
    17 
    17 
    18 import sys, getopt
    18 import sys, getopt
    19 import os
    19 import os
    20 import pynotify
    20 import pynotify
   238                         buddy = VOICEMAP[jid]
   238                         buddy = VOICEMAP[jid]
   239                     say(buddy, "is online now.")
   239                     say(buddy, "is online now.")
   240 
   240 
   241     elif event == 'UNREAD':
   241     elif event == 'UNREAD':
   242         # arg1 is the number of unread buffers
   242         # arg1 is the number of unread buffers
       
   243         unread_all, unread_attn, unread_muc, unread_muc_attn = args[1:5]
       
   244         unread = int(unread_all) - (int(unread_muc) - int(unread_muc_attn))
       
   245         if unread == int(unread_all):
       
   246             unread_str = unread_all
       
   247         else:
       
   248             unread_str = str(unread) + "/" + unread_all
   243         if OPT['unread_file'] != '':
   249         if OPT['unread_file'] != '':
   244             fileh = open(OPT['unread_file'], 'w')
   250             fileh = open(OPT['unread_file'], 'w')
   245             fileh.write(arg1)
   251             fileh.write(unread_str)
   246             fileh.close()
   252             fileh.close()
   247 
   253 
   248 
   254 
   249 ##### MAIN #####
   255 ##### MAIN #####
   250 
   256