~ubuntu-branches/ubuntu/precise/gozerbot/precise

« back to all changes in this revision

Viewing changes to gozerplugs/plugs/autovoice.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Malcolm
  • Date: 2008-06-02 19:26:39 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080602192639-3rn65nx4q1sgd6sy
Tags: 0.8.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# plugins/autovoice.py
2
 
#
3
 
#
4
 
 
5
 
""" do voice on join """
6
 
 
7
 
__copyright__ = 'this file is in the public domain'
8
 
 
9
 
from gozerbot.commands import cmnds
10
 
from gozerbot.callbacks import callbacks
11
 
from gozerbot.examples import examples
12
 
from gozerbot.plughelp import plughelp
13
 
 
14
 
plughelp.add('autovoice', 'enable auto voicing of people join .. commands \
15
 
work for the channels the commands are given in')
16
 
 
17
 
def preautovoice(bot, ievent):
18
 
    """ precondition on auto-op .. we must be op """
19
 
    if ievent.channel in bot.state['opchan']:
20
 
        return 1
21
 
 
22
 
def cbautovoice(bot, ievent):
23
 
    """ autovoice callback """
24
 
    chandata = 0
25
 
    try:
26
 
        chandata = bot.channels[ievent.channel]['autovoice']
27
 
    except KeyError:
28
 
        return
29
 
    if chandata:
30
 
        bot.voice(ievent.channel, ievent.nick)
31
 
 
32
 
callbacks.add('JOIN', cbautovoice, preautovoice)
33
 
 
34
 
def handle_autovoiceon(bot, ievent):
35
 
    """ autovoice-on .. enable autovoice for channel the command was given \
36
 
        in """
37
 
    bot.channels[ievent.channel]['autovoice'] = 1
38
 
    ievent.reply('autovoice enabled on %s' % ievent.channel)
39
 
 
40
 
cmnds.add('autovoice-on', handle_autovoiceon, 'OPER')
41
 
examples.add('autovoice-on', 'enable autovoice on channel in which the \
42
 
command is given', 'autovoice-on')
43
 
 
44
 
def handle_autovoiceoff(bot, ievent):
45
 
    """ autovoice-off .. disable autovoice for the channel the command was \
46
 
        given in """
47
 
    bot.channels[ievent.channel]['autovoice'] = 0
48
 
    ievent.reply('autovoice disabled on %s' % ievent.channel)
49
 
 
50
 
cmnds.add('autovoice-off', handle_autovoiceoff, 'OPER')
51
 
examples.add('autovoice-off', 'disable autovoice on channel in which \
52
 
the command is given', 'autovoice-off')