Exemplo n.º 1
0
    def send_avatar(self, friend_number):
        """
        Отправка аватара

        Агрументы:
            friend_number (int) -- Номер друга
        """
        if len(self.options.avatar) == 0 or not os.path.isfile(self.options.avatar):
            return

        friend_name = self.tox_friend_get_name(friend_number)
        self.verbose("Send avatar to {0}/{1}".format(friend_name, friend_number))

        f = EchoBotFile()

        f.kind = ToxCore.TOX_FILE_KIND_AVATAR
        f.size = os.path.getsize(self.options.avatar)
        f.read = True
        f.path = self.options.avatar
        f.fd   = open(f.path, "rb")

        data = f.fd.read()
        f.fd.seek(0, 0)

        f.id   = ToxCore.tox_hash(data)
        f.name = f.id

        file_number = self.tox_file_send(friend_number, ToxCore.TOX_FILE_KIND_AVATAR, f.size, f.id, f.name)

        if friend_number not in self.files:
            self.files[friend_number] = {}

        self.files[friend_number][file_number] = f
Exemplo n.º 2
0
    def defaultOptions():
        """
        Опции по умолчанию

        Результат (dict):
            Словарь опций по умолчанию
        """
        tox_opts = ToxCore.tox_options_default()

        options = {
            "debug"           : "yes",
            "verbose"         : "yes",
            "name"            : "EchoBot",
            "status_message"  : "Think Safety",
            "avatar"          : "echobot.png",
            "save_file"       : "echobot.data",
            "save_tmp_file"   : "echobot.data.tmp",
            "save_interval"   : "300",
            "bootstrap_host"  : "178.62.250.138",   # https://wiki.tox.chat/users/nodes
            "bootstrap_port"  : "33445",
            "bootstrap_key"   : "788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B",
            "ipv6_enabled"    : "yes" if tox_opts["ipv6_enabled"] else "no",
            "udp_enabled"     : "yes" if tox_opts["udp_enabled"]  else "no",
            "proxy_type"      : "",
            "proxy_host"      : "" if tox_opts["proxy_host"] is None else tox_opts["proxy_host"],
            "proxy_port"      : str(tox_opts["proxy_port"]),
            "start_port"      : str(tox_opts["start_port"]),
            "end_port"        : str(tox_opts["end_port"]),
            "tcp_port"        : str(tox_opts["tcp_port"]),
            "accept_avatars"  : "no",
            "max_avatar_size" : "0",
            "avatars_path"    : "",
            "accept_files"    : "no",
            "max_file_size"   : "0",
            "files_path"      : "",
        }

        if tox_opts["proxy_type"] == ToxCore.TOX_PROXY_TYPE_SOCKS5:
            options["proxy_type"] = "socks"
        elif tox_opts["proxy_type"] == ToxCore.TOX_PROXY_TYPE_HTTP:
            options["proxy_type"] = "http"
        elif tox_opts["proxy_type"] != ToxCore.TOX_PROXY_TYPE_NONE:
            raise NotImplementedError("Unknown proxy_type: {0}".format(tox_opts["proxy_type"]))

        return options
Exemplo n.º 3
0
    def defaultOptions():
        """
        Опции по умолчанию

        Результат (dict):
            Словарь опций по умолчанию
        """
        tox_opts = ToxCore.tox_options_default()

        options = {
            "debug":
            "yes",
            "verbose":
            "yes",
            "name":
            "EchoBot",
            "status_message":
            "Think Safety",
            "avatar":
            "echobot.png",
            "save_file":
            "echobot.data",
            "save_tmp_file":
            "echobot.data.tmp",
            "save_interval":
            "300",
            "bootstrap_host":
            "178.62.250.138",  # https://wiki.tox.chat/users/nodes
            "bootstrap_port":
            "33445",
            "bootstrap_key":
            "788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B",
            "ipv6_enabled":
            "yes" if tox_opts["ipv6_enabled"] else "no",
            "udp_enabled":
            "yes" if tox_opts["udp_enabled"] else "no",
            "proxy_type":
            "",
            "proxy_host":
            "" if tox_opts["proxy_host"] is None else tox_opts["proxy_host"],
            "proxy_port":
            str(tox_opts["proxy_port"]),
            "start_port":
            str(tox_opts["start_port"]),
            "end_port":
            str(tox_opts["end_port"]),
            "tcp_port":
            str(tox_opts["tcp_port"]),
            "accept_avatars":
            "no",
            "max_avatar_size":
            "0",
            "avatars_path":
            "",
            "accept_files":
            "no",
            "max_file_size":
            "0",
            "files_path":
            "",
        }

        if tox_opts["proxy_type"] == ToxCore.TOX_PROXY_TYPE_SOCKS5:
            options["proxy_type"] = "socks"
        elif tox_opts["proxy_type"] == ToxCore.TOX_PROXY_TYPE_HTTP:
            options["proxy_type"] = "http"
        elif tox_opts["proxy_type"] != ToxCore.TOX_PROXY_TYPE_NONE:
            raise NotImplementedError("Unknown proxy_type: {0}".format(
                tox_opts["proxy_type"]))

        return options
Exemplo n.º 4
0
 def __init__(self):
     opts = ToxCore.tox_options_default()
     for key, value in iteritems(opts):
         self.__dict__[key] = value