All pastes #908070 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-02-18 02:52 UTC
rendered paste body
ben@ben-laptop:~/Projects/trollbot$ ./trollbot
#################################################
# Trollbot v1.0.0, written by                   #
#################################################
# poutine/DALnet - Lead Developer               #
# kicken/DALnet  - Javascript Support and Core  #
# comcor/DALnet  - Python Support               #
#################################################
# Reading configuration                         #
#################################################
Configuration Parser Output:
[python] Initialized interpreter
[python] Loaded trollbot binding module
[python] code: import imp
import trollbot
import sys

NETWORKS = {}

#TrollbotNetworkInterface
#Marshals access to the trollbot module for the given network.
#Each script loaded will have a reference to an instance of this
#object for the network it is attached to

class TrollbotNetworkInterface:

   def __init__(self, network):
      self.network = network #ptr to TB net struct
      self.modules = {}
   #end __init__

   def load_module(self, name):
      ok = False
      if (name.find("/") != -1):
         comps = name.split("/")
         path = "/".join(comps[:-1])
         name = comps[-1]
         if path not in sys.path:
            sys.path.insert(0,path)
      #end path handling

      #strip .py off
      if (name[-3:] == ".py"):
         name = name[:-3]

      fp, pathname, description = imp.find_module(name)

      try:
         module = imp.load_module(name, fp, pathname, description)
         if module is not None:
            #pass module a reference to us
            module.trollbot = self
            #initialize our module
            if getattr(module, "load") != None:
               module.load()
            else:
               raise "Missing load() method for module!"
            #save the module for access later
            self.modules[name] = module
            ok = True
      finally:
         if fp:
            fp.close
      return ok
   #end load_module

   def bind(self,*args):
      trollbot.bind(self.network, *args)

   def putserv(self, *args):
      trollbot.putserv(self.network, *args)

   def call_method(self,callback, *args):
      #get module name
      (module, method) = callback.split(".")
      if self.modules.has_key(module):
         cb = getattr(self.modules[module], method)
         cb(*args)

#end TrollbotNetworkInterface


##
## INTERNAL FUNCTIONS
##
## Please don't call these unless you know what you are doing.
## These are meant to be called through the Python C/API
##

def __TB_init_network(network):
   if not NETWORKS.has_key(network):
      NETWORKS[network] =
[python] Loaded internal core module
[python] initializing network context DALnet
[python] loading module `scripts/test.py' for network DALnet
Could not load Javascript file (scripts/cocks.js)
test loaded
Loaded cryptoquote