Ported to Python 3
This commit is contained in:
50
main.py
50
main.py
@@ -1,9 +1,40 @@
|
||||
from bootstrap import node_generator
|
||||
from bot import *
|
||||
from callbacks import init_callbacks
|
||||
# -*- 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 <ToxID> <file_name> - send file to friend (get access)\n
|
||||
share --all <file_name> - send file to all friends (get access)\n
|
||||
size <file_name> - get size of file (get access)\n
|
||||
get <file_name> - get file with specified filename (get access)\n
|
||||
get --all - get all files (get access)\n
|
||||
stats - show statistics (write access)\n
|
||||
del <file_name> - remove file with specified filename (delete access)\n
|
||||
rename <file_name> --new <new_file_name> - rename file (delete access)\n
|
||||
user <ToxID> <rights> - new rights (example: rwdm) for user (masters only)\n
|
||||
status <new_status> - new status message (masters only)\n
|
||||
name <new_name> - new name (masters only)\n
|
||||
message <ToxID> <message_text> - send message to friend (masters only)\n
|
||||
message --all <message_text> - send message to all friends (masters only)\n
|
||||
stop - stop bot (masters only)\n
|
||||
fsize <folder_size_in_MB> - 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):
|
||||
|
||||
@@ -13,7 +44,7 @@ class FileBot(object):
|
||||
self.stop = False
|
||||
self.profile = None
|
||||
self.path = path
|
||||
print 'FileBot v0.1.2'
|
||||
LOG.info('FileBot v0.1.2+')
|
||||
|
||||
def main(self):
|
||||
self.tox = tox_factory(ProfileHelper.open_profile(self.path))
|
||||
@@ -23,7 +54,7 @@ class FileBot(object):
|
||||
self.tox.bootstrap(*data)
|
||||
settings = Settings()
|
||||
self.profile = Bot(self.tox)
|
||||
print 'Iterate'
|
||||
LOG.debug('Iterate')
|
||||
try:
|
||||
while not self.stop:
|
||||
self.tox.iterate()
|
||||
@@ -36,10 +67,9 @@ class FileBot(object):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1:
|
||||
path = sys.argv[1]
|
||||
bot = FileBot(path)
|
||||
bot.main()
|
||||
else:
|
||||
if len(sys.argv) <= 1:
|
||||
raise IOError('Path to save file not found')
|
||||
path = sys.argv[1]
|
||||
bot = FileBot(path)
|
||||
bot.main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user