Skip to content

Instantly share code, notes, and snippets.

c = ConfigObj("socuppet.conf")
p = PluginManager()
f = BotFactory(c, p)
if "servers" in c:
for name, server in c['servers'].iteritems():
botService = internet.TCPClient(server["host"], 6667, f)
botService.startService()
reactor.addSystemEventTrigger('before', 'shutdown', botService.stopService)
from collections import defaultdict
class Manager(object):
def __init__(self):
self.triggers = defaultdict(list) # event: [func, ]
def register(self, *events):
def register_for_event(func):
for event in events:
self.triggers[event.lower()].append(func)
return func
from twisted.words.protocols import irc
from twisted.internet import protocol, reactor
import traceback
class Bot(irc.IRCClient):
nickname = "SocPuppet"
def try_except(self, func, *args):
try:
return func(*args)
from twisted.application import internet, service
from twisted.words.protocols import irc
from twisted.internet import protocol
class Bot(irc.IRCClient):
nickname = "SocPuppet"
def connectionMade(self):
irc.IRCClient.connectionMade(self)
print "Connected"
from twisted.web import server, resource
from twisted.internet import reactor
class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "html"
def render_POST(self, request):
print request
<EntityReborn|> SocPuppet: reloadplugins
<SocPuppet> Ok!
<EntityReborn|> SocPuppet: commit_check
<EntityReborn|> SocPuppet: commit_last
<SocPuppet> http://github.com/EntityReborn/SocPuppet/commit/0ed8de946ab353512a5de423a639d3b722efb089: Added commit plugin.
<EntityReborn|> and, I'm gunna push a commit right now.
<SocPuppet> http://github.com/EntityReborn/SocPuppet/commit/8b5cbd53b188492c4d7b750793be9ae837799392: Refined several things
... other html
<div style="width:25%;float:left">
<a href="a/" class="ls1">a</a>
<a href="s/" class="ls3">s</a>
<a href="d/" class="ls4">d</a>
<a href="f/" class="ls1">f</a>
</div>
... other html
<div style="width:25%;float:left">
@EntityReborn
EntityReborn / downloader.py
Created April 4, 2011 20:30
simple image downloader, currently used for adult content
import re, os
import urllib2
baseurl = "http://hof.voyeurweb.com/gallery/"
nexturlre = re.compile(r'Overview Page</a> \| <a href="([^"]*)">')
imgurlre = re.compile(r'<img src="([^"]*)" alt="([^"]*)" border="0" />')
def downloadNext(url, cat):
print "==================\nOpening %s"%url
f = urllib2.urlopen(url)
def save_page(request, page_name):
content = request.POST["content"]
try:
page = Page.objects.get(pk=page_name)
page.content = content
if "tags" in request.POST:
tags = request.POST['tags'].split()
taglist = [Tag.objects.get_or_create(name=tag)[0] for tag in tags]
from django import template
from socialites.wiki.models import Page
import re
wikilink = re.compile(r"\[\[([^\]]+)\]\]")
register = template.Library()
@register.filter
def wikify(value):
for match in wikilink.finditer(value):