def presenceHandler(self, conn, presence): UID = self.getUIDfromPresence(presence) if presence.getType()=='unavailable': print presence.getFrom(), ",", presence.getType() connectioncount = 0 if presence.getFrom() in roster: roster.remove(presence.getFrom()) for connection in roster: connectionString = str(connection) if connectionString[0:connectionString.find('/')] == UID: if connection != presence.getFrom(): #user still connected from somewhere else connectioncount = connectioncount + 1 if connectioncount == 0: #wait 30 seconds #then kill #import pdb; pdb.set_trace() killList[UID] = int(time.time()) elif presence.getType()=='subscribe': jid = presence.getFrom().getStripped() self.authorize(jid) else: print presence.getFrom(), ",", presence.getType() if UID in killList: del killList[UID] if presence.getFrom() not in roster: roster.append(presence.getFrom()) #if "desultir" in presence.getFrom().getStripped(): #self.replyMessage(presence.getFrom(), "hai") GtalkRobot.presenceHandler(self, conn, presence)
def start(self): name = self.getCfgValue('account', 'name') pwd = self.getCfgValue('account', 'pwd') show = self.getCfgValue('init_param', 'show') status = self.getCfgValue('init_param', 'status') self.setState(show, status) self.gnotebook = GNotebook(name, pwd) if self.gnotebook: print "Google Notebook connected!" GtalkRobot.start(self, name, pwd)
def __init__(self, ssh_pool): GtalkRobot.__init__(self) self.ssh_provider_pool = ssh_pool self.command_executor = CommandParseAndExecutor(ssh_pool)
# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # PyGtalkRobot Homepage: http://code.google.com/p/pygtalkrobot/ # RaspiBot Homepage: http://code.google.com/p/pygtalkrobot/ # import time # import RPi.GPIO as GPIO from PyGtalkRobot import GtalkRobot from configs.config import configs from configs.strings import strings # GPIO.setmode(GPIO.BOARD) # or GPIO.setmode(GPIO.BCM) ############################################################################################################################ if __name__ == "__main__": bot = GtalkRobot(configs().settings["server"], configs().settings["port"], debug=configs().debug) bot.setState("available", strings().status) bot.start(configs().settings["BOT_GTALK_USER"], configs().settings["BOT_GTALK_PASS"])