Esempio n. 1
0
File: bot.py Progetto: j616/BeardBot
    def die(self, *args, **kwargs):
        # Store a list of loaded modules before going down
        pickle.dump(self.modules.keys(), open(self.channel + "_modules.db", "w"))

        # Kill all the modules
        for module in self.modules.values():
            module.die()

            # Disconnect and quit
        SingleServerIRCBot.die(self, *args, **kwargs)
Esempio n. 2
0
    def on_pubmsg(self, c, e):
        cmd = e.arguments[0].split()[0]

        if cmd[0] == "!":
            cmd = cmd[1:].upper()
            if commands.has_key(cmd):
                commands[cmd].index(self, c, e)
            else:
                cmd=e.arguments[0]

        if cmd=='!kuole':
            self.running = False
            SingleServerIRCBot.die(self, 'By your command')
        if (cmd=='!ovi') or (cmd=='!door'):
            self.sayDoorStatus()
        if (cmd=='!valot') or (cmd=='!lights'):
            self.say('lights are ' + ('on' if self.lightStatus else 'off'))
        if (cmd=='!checksum') or (cmd=='!checksum'):
            self.say('pixelvar: ' + str(self.camera.checkSum()))
        if (cmd=='!printer') or (cmd=='!tulostin'):
            ping_response = subprocess.Popen(["/bin/ping", "-c1", "-w2", self.printer_ip], stdout=subprocess.PIPE).stdout.read()
            if ('rtt' in ping_response):
                self.say('printer is online')
            else:
                self.say('printer is offline')
            print('p: ' + str(ping_response))

        if cmd=='!shot':
            self.camera.takeShotCommand()
            c.privmsg(self.channel, self.shoturl + ('' if self.lightStatus else ' (pretty dark, eh)'))
        if cmd=='!gitpull':
            os.system('/home/pi/pajabot/scripts/gitpull.sh')
            c.privmsg(self.channel, 'Pulled from git, restarting..')
            self.restart_program()
        if cmd=='!update':
            self.updateStatus()
            c.privmsg(self.channel, 'Done')
Esempio n. 3
0
    def on_pubmsg(self, c, e):
        cmd = e.arguments[0].split()[0]

        if cmd[0] == "!":
            cmd = cmd[1:].upper()
            if commands.has_key(cmd):
                commands[cmd].index(self, c, e)
            else:
                cmd=e.arguments[0]

        if cmd=='!kuole':
            self.running = False
            SingleServerIRCBot.die(self, 'By your command')
        if (cmd=='!ovi') or (cmd=='!door'):
            self.sayDoorStatus()
        if (cmd=='!valot') or (cmd=='!lights'):
            self.say('lights are ' + ('on' if self.lightStatus else 'off'))
        if (cmd=='!checksum') or (cmd=='!checksum'):
            self.say('pixelvar: ' + str(self.camera.checkSum()))
        if (cmd=='!printer') or (cmd=='!tulostin'):
            self.sayPrinterStatus()

#        if (cmd=='!printteri'):
#            commands['PRINTTERI'].index(self, c,e)


        if cmd=='!shot':
            self.camera.takeShotCommand()
            c.privmsg(self.channel, self.shoturl + ('' if self.lightStatus else ' (pretty dark, eh)'))
        if cmd=='!gitpull':
            os.system('/home/ovi/pajabot/scripts/gitpull.sh')
            c.privmsg(self.channel, 'Pulled from git, restarting..')
            self.restart_program()
        if cmd=='!update':
            self.updateStatus()
            c.privmsg(self.channel, 'Done')
Esempio n. 4
0
    def restart_program(self):

        print ('Restarting')
        subprocess.Popen("/home/ovi/pajabot/bot/pajabot.py", shell=False)
        SingleServerIRCBot.die(self, 'By your command')
        exit("updating")