This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before | |
# In plugin manager: | |
def register_trigger(self, func, *events): | |
for event in events: | |
self.triggers[event.upper()].append(func) | |
# In plugin: | |
def initialize(self, *args, **kwargs): | |
manager.register_trigger(self.on_welcome, "IRC_RPL_WELCOME") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import panglery | |
class Base(object): | |
p = panglery.PanglerAggregate('hooks') | |
def __init__(self): | |
self.attr = True | |
class Plugin(Base): | |
hooks = panglery.Pangler() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import Column, Integer, String, MetaData | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
class User(Base): | |
__tablename__ = 'users' | |
id = Column(Integer, primary_key=True) | |
name = Column(String) | |
fullname = Column(String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
def taskexists(pid): | |
if sys.platform == "win32": | |
import ctypes | |
import win32con | |
h = ctypes.windll.kernel32.OpenProcess(win32con.PROCESS_ALL_ACCESS, False, pid) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HACK-n-PATCH! Allow dotted syntax access. | |
def monkeypatch1(self, name): | |
if self.has_key(name): | |
return self[name] | |
super(ConfigObj, self).__getattr__(name) | |
ConfigObj.__getattr__ = monkeypatch1 | |
def monkeypatch2(self, name): | |
if self.has_key(name): | |
return self[name] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
numchars = 41 | |
wait = 0.25 | |
x = "." | |
o = " " | |
def wave(x, o): | |
for num in xrange(1, numchars, 2): | |
time.sleep(wait) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Manager(object): | |
def __init__(self): | |
self.funcs = {} | |
def regTrigger(self, func, trig): | |
trig = trig.lower() | |
if not trig in self.funcs: | |
self.funcs[trig] = [] | |
self.funcs[trig].append(func) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socbot.pluginbase import Base | |
from twisted.application import internet, service | |
from twisted.web import resource, server | |
class Simple(resource.Resource): | |
isLeaf = True | |
def render_GET(self, request): | |
return "<html>Hello, world!</html>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socbot.pluginbase import Base | |
from twisted.application import internet | |
from twisted.web import resource, server | |
class Simple(resource.Resource): | |
isLeaf = True | |
def render_GET(self, request): | |
return "<html><head><title>Ohai2</title></head><body>Hello, world 2!</body></html>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socbot.pluginbase import Base | |
from twisted.application import internet | |
from twisted.web import resource, server | |
class Plugin(Base): | |
class Simple(resource.Resource): | |
isLeaf = True | |
def render_GET(self, request): | |
line = "<html><head><title>Ohai2</title></head><body>Hello, world 2!</body></html>" | |
self.log.info(line) |