# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*- """ help - list of commands\n rights - get access rights\n files - show list of files (get access)\n id - get bot's id (get access)\n share - send file to friend (get access)\n share --all - send file to all friends (get access)\n size - get size of file (get access)\n get - get file with specified filename (get access)\n get --all - get all files (get access)\n stats - show statistics (write access)\n del - remove file with specified filename (delete access)\n rename --new - rename file (delete access)\n user - new rights (example: rwdm) for user (masters only)\n status - new status message (masters only)\n name - new name (masters only)\n message - send message to friend (masters only)\n message --all - send message to all friends (masters only)\n stop - stop bot (masters only)\n fsize - set folder size in MB (masters only)\n Users with write access can send files to bot. """ import time import sys from bootstrap import node_generator from bot import Bot, tox_factory, ProfileHelper from callbacks import init_callbacks from settings import Settings global LOG import logging logging.basicConfig(level=10) LOG = logging.getLogger(__name__) class FileBot(object): def __init__(self, path): super(FileBot, self).__init__() self.tox = None self.stop = False self.profile = None self.path = path LOG.info('FileBot v0.1.2+') def main(self): self.tox = tox_factory(ProfileHelper.open_profile(self.path)) init_callbacks(self.tox) # bootstrap for data in node_generator(): self.tox.bootstrap(*data) settings = Settings() self.profile = Bot(self.tox) LOG.debug('Iterate') try: while not self.stop: self.tox.iterate() time.sleep(self.tox.iteration_interval() / 1000.0) except KeyboardInterrupt: settings.save() data = self.tox.get_savedata() ProfileHelper.save_profile(data) del self.tox if __name__ == '__main__': if len(sys.argv) <= 1: raise IOError('Path to save file not found') path = sys.argv[1] bot = FileBot(path) bot.main()