コード例 #1
0
ファイル: bot.py プロジェクト: do3cc/starzel.whoiscalling
def run(username, password, room, fritzbox):
    logging.debug("Started at %s", datetime.now().isoformat())
    bot = JabberBot(username, password)

    telnet = Telnet(fritzbox, '1012')

    while True:
        # ugly, but seems to be the only way to stay on
        bot.join_room(room)
        logging.debug("Loop started at %s", datetime.now().isoformat())
        data = telnet.read_until('SIP0;', 300)
        number = '\n'.join(only_number.findall(data))
        if number:
            logging.debug("Sending a message at %s", datetime.now().isoformat())
            bot.send(room, "Call from " + number, message_type='groupchat')
        else:
            what = bot.conn.Process(1)
            if what != '0' and what != None:
                logging.debug("What is this %s", what)
            elif what == None:
                logging.debug("Reconnecting")
                bot.conn.reconnectAndReauth()
コード例 #2
0
ファイル: bot.py プロジェクト: do3cc/starzel.whoiscalling
def run(username, password, room, fritzbox):
    logging.debug("Started at %s", datetime.now().isoformat())
    bot = JabberBot(username, password)

    telnet = Telnet(fritzbox, '1012')

    while True:
        # ugly, but seems to be the only way to stay on
        bot.join_room(room)
        logging.debug("Loop started at %s", datetime.now().isoformat())
        data = telnet.read_until('SIP0;', 300)
        number = '\n'.join(only_number.findall(data))
        if number:
            logging.debug("Sending a message at %s",
                          datetime.now().isoformat())
            bot.send(room, "Call from " + number, message_type='groupchat')
        else:
            what = bot.conn.Process(1)
            if what != '0' and what != None:
                logging.debug("What is this %s", what)
            elif what == None:
                logging.debug("Reconnecting")
                bot.conn.reconnectAndReauth()
コード例 #3
0
from jabberbot import JabberBot
import random
import sys
import os
import time

# what is my account
username = '******'
# what is the password for that account
password = ''
# what is the account which should receive the messages
remotebot = '*****@*****.**'
# time between two updates in seconds
sleeptime = 60
# we are working via ping - so what should i ping?
# default sould be slotmachine (printerserver)
pinghost = "10.0.1.10"
# command to send to the remote bot if everything is fine
cmdfine = "setoffen"
# command to send to the remote bot if encountering a problem
cmdfail = "setzu"

########### END CONFIG

tmp = os.system("ping -c 1 " + pinghost)
bot = JabberBot(username, password)
if tmp == 0:
    bot.send(remotebot, cmdfine)
else:
    bot.send(remotebot, cmdfail)