~habnabit/infobat/chatty

« back to all changes in this revision

Viewing changes to infobat/irc.py

  • Committer: Aaron Gallagher
  • Date: 2010-04-29 07:21:45 UTC
  • Revision ID: habnabit@gmail.com-20100429072145-7ff9klf5rg8zu5j3
Miscellaneous fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import sys
18
18
import re
19
19
 
20
 
_lol_regex = re.compile(r'\b([lo]{3,}|rofl+|lmao+)z*\b', re.I)
 
20
_lol_regex = re.compile(r'\b(lo+l[lo]*|rofl+|lmao+)z*\b', re.I)
21
21
_lol_messages = [
22
22
    '%s is a no-LOL zone.',
23
23
    'i mean it: no LOL in %s.',
70
70
    def signedOn(self):
71
71
        nickserv_pw = conf['irc.nickserv_pw']
72
72
        if nickserv_pw:
73
 
            self.msg('NickServ', 'identify %s' % nickserv_pw)
 
73
            self.msg('NickServ', 'identify %s' % nickserv_pw.encode())
74
74
        else:
75
75
            self.autojoinChannels()
76
76
        self.startTimer('serverPing', 60)
152
152
            return
153
153
        self.db.learn(self.sanitize_learn_input(string), action)
154
154
 
155
 
    def sanitize_learn_input(self, string, channel):
 
155
    def sanitize_learn_input(self, string):
156
156
        """Remove extraneous/irrelevant data from input to markov chain
157
157
        
158
158
        - remove nickname prefixes: "nick: foo bar" -> "foo bar"
423
423
        self.msg(target, result)
424
424
 
425
425
    def infobat_divine(self, target, *seed):
 
426
        fortunes = conf['misc.magic8_file']
 
427
        if not fortunes:
 
428
            log.msg('no magic8 file')
 
429
            return
426
430
        self.me(target, 'shakes the psychic black sphere.')
427
431
        r = random.Random(''.join(seed) + datetime.now().isoformat())
428
 
        st = open('magic8.txt')
 
432
        st = open(fortunes.encode())
429
433
        l = st.readlines()
430
434
        st.close()
431
435
        l = r.choice(l).strip()