Skip to content

Commit

Permalink
Switch to Foolscap
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny O'Brien authored and Danny O'Brien committed Aug 16, 2012
1 parent 7f42b0a commit 444517e
Showing 1 changed file with 19 additions and 32 deletions.
51 changes: 19 additions & 32 deletions consenso/bot/tac.py
@@ -1,10 +1,11 @@
#!/usr/bin/env python
##
# ircbot.tac
# tac.py
###
"""ircbot.tac
"""tac.py
Twisted Application .tac file for the Consenso process.
Twisted Application .tac file
See <http://twistedmatrix.com/documents/current/core/howto/application.html>
"""

Expand All @@ -13,39 +14,25 @@
__contributors__ = None
__license__ = "GPL v3"

from twisted.words.protocols import irc
from twisted.internet import protocol
from twisted.application import service


class ConsensoBot(irc.IRCClient):
def _get_nickname(self):
return self.factory.nickname
nickname = property(_get_nickname)

def signedOn(self):
self.join(self.factory.channel)
print "Signed on as %s." % (self.nickname,)

def joined(self, channel):
print "Joined %s." % (channel,)

def privmsg(self, user, channel, msg):
print msg
import os

from twisted.application import service
from foolscap.api import Referenceable, Tub

class ConsensoBotFactory(protocol.ClientFactory):
protocol = ConsensoBot
import consenso.directories

def __init__(self, channel, nickname='ConsensoSimple'):
self.channel = channel
self.nickname = nickname

def clientConnectionLost(self, connector, reason):
print "Lost connection (%s), reconnecting." % (reason,)
connector.connect()
class RemoteControl(Referenceable):
def remote_irc_joint(self, host, port, group=None, nick=None):
print "I am trying to join {} on {}:{} as {}".format(group, host, port, nick)

def clientConnectionFailed(self, connector, reason):
print "Could not connect: %s" % (reason,)
myserver = RemoteControl()
tub = Tub(certFile=os.path.join(consenso.directories.foolscap_dir, "pb2server.pem"))
tub.listenOn("tcp:12345")
tub.setLocation("localhost:12345")
url = tub.registerReference(myserver, "remote-control")
print("pid ", os.getpid())
print("furl ", url)

application = service.Application("Consenso Twisted Application")
tub.setServiceParent(application)

0 comments on commit 444517e

Please sign in to comment.