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