Вопрос

I'm using the markov chain irc bot based on twisted. Socks proxy may be putty, listening on port 22. Adding the following code to the above client (at the top of the py file) didn't help:

import socks, socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,
    'localhost', 22)
socket.socket = socks.socksocket

Whereas, doing so solved the problem while using SimpleIRCClient from irclib, however irclib doesn't fit other requirements.

Thanks.

Это было полезно?

Решение 2

Thanks Jean-Paul Calderone. The following code worked for me.

from twisted.internet.endpoints import TCP4ClientEndpoint 
from txsocksx.client import SOCKS5ClientEndpoint

if __name__ == "__main__":
    chan = "django-hotclub"
    chain_length = 5

    myID = sys.argv[1]
    counterpartID = sys.argv[2]

    puttyEndPoint = TCP4ClientEndpoint(reactor, '127.0.0.1', 22)
    ircEndpoint = SOCKS5ClientEndpoint('irc.freenode.net', 6667, puttyEndPoint)
    d = ircEndpoint.connect(MomBotFactory('#' + chan, myID, counterpartID, chain_length, chattiness=0.05))
    reactor.run()

Другие советы

Use a socks client library - https://github.com/habnabit/txsocksx.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top