Ejemplo n.º 1
0
#!/usr/bin/python
# -*- tab-width: 4; use-tabs: 1; coding: utf-8 -*-
# vim:tabstop=4:noexpandtab:
"""
A Basic bot that mumbles on command
"""
from twisted.words.protocols import irc
from twisted.internet import reactor, protocol
from mumblr.data import WordDB

words = WordDB()

# Load data
words.load_linefile(open('data.mumble'))

def mumble():
	return words.genline()

class CommandBot(irc.IRCClient):
	"""
	A bot the mumbles on command.
	"""
	
	nickname = "astro73|mumble"
	
	def signedOn(self):
		"""Called when bot has succesfully signed on to server."""
		for c in self.factory.channels:
			self.join(c)

	def joined(self, channel):
Ejemplo n.º 2
0
#!/usr/bin/python
# -*- tab-width: 4; use-tabs: 1; coding: utf-8 -*-
# vim:tabstop=4:noexpandtab:
"""
A basic test program to help flesh out markov chains.
"""
from __future__ import division
from random import SystemRandom
from mumblr.data import WordDB

words = WordDB()

# Load data
words.load_linefile(open('data.mumble'))

# Generate a sentence
for _ in range(10):
	sentence = words.genline()
	while len(sentence.split()) < 5:
		sentence = words.genline()
	print sentence