Skip to content

Commit

Permalink
botko responds when poked
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizec committed Apr 25, 2012
1 parent 5857006 commit ed33147
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/chitchat.py
Expand Up @@ -5,6 +5,8 @@
from math import ceil
import random

import settings

def take(n, iterable):
"Return first n items of the iterable as a list"
return list(islice(iterable, n))
Expand Down Expand Up @@ -38,14 +40,17 @@ def chat(self, line):
self.corpus.add(" ".join(self.buffer))
del self.buffer[:]

speak = self.should_speak()
speak = self.should_speak() or self.mentioned(message)
msg = self.talk() if speak else ""

self.counter += 1

return speak, msg

def talk(self):
if self.counter < self.MSGS:
return "I'm just admiring the shape of your skull"

self.corpus.rewind()
line = take(ceil(sum(self.avg_len)/self.MSGS),
self.corpus)
Expand Down Expand Up @@ -73,3 +78,6 @@ def should_speak(self):
# ratio between speed of last <10> messages and speed of last <60>
# determines probability of speaking
return random.random() > 1-float(now-oldest_10)/float(now-oldest)

def mentioned(self, msg):
return settings.BOT_NICK in msg
4 changes: 2 additions & 2 deletions src/settings.py
Expand Up @@ -6,8 +6,8 @@
TOKEN = "16edde56d1801c65ec96a4d607a67d89"
SERVER_URL = "http://localhost:8000/irc/add/"
#BOT_NICK = "botko_"
BOT_NICK = "botko-swizec"
BOT_NAME = "botko-swizec"
BOT_NICK = "_chatty-botko_"
BOT_NAME = "chatty-botko"
#CHANNEL = "#smotko-testing"
CHANNEL = "#swizec-testing"
IRC_SERVER = 'irc.freenode.org'
Expand Down

0 comments on commit ed33147

Please sign in to comment.