]>
jfr.im git - irc/rizon/acid.git/blob - pyva/src/main/python/erepublik/cmd_private.py
1 from cmd_manager
import *
2 from datetime
import datetime
4 def private_channel_request(self
, manager
, opts
, arg
, channel
, sender
):
5 if self
.channels
.is_valid(arg
):
6 self
.msg(channel
, "I'm already in @b%s@b." % arg
)
7 elif self
.channels
.is_banned(arg
):
8 chan
= self
.channels
[arg
]
9 self
.elog
.request('Request for banned channel @b%s@b from @b%s@b.' % (arg
, sender
))
10 message
= 'Request failed, channel @b%s@b was banned by @b%s@b.' % (arg
, chan
.ban_source
)
12 if chan
.ban_reason
!= None:
13 message
+= ' Reason: @b%s@b.' % chan
.ban_reason
15 if chan
.ban_expiry
!= None:
16 message
+= ' Expires: @b%s@b.' % datetime
.fromtimestamp(chan
.ban_expiry
)
18 self
.msg(channel
, message
)
19 self
.msg(channel
, 'Please email @c3erepublik@rizon.net@o to appeal.')
21 self
.auth
.request(sender
, arg
, 'request')
23 def private_channel_remove(self
, manager
, opts
, arg
, channel
, sender
):
24 if not self
.channels
.is_valid(arg
):
25 self
.msg(channel
, "I'm not in @b%s@b." % arg
)
27 self
.auth
.request(sender
, arg
, 'remove')
29 def private_channel_news(self
, manager
, opts
, arg
, channel
, sender
):
30 if not self
.channels
.is_valid(arg
):
31 self
.msg(channel
, "I'm not in @b%s@b." % arg
)
33 self
.auth
.request(sender
, arg
, 'news')
35 def private_channel_nonews(self
, manager
, opts
, arg
, channel
, sender
):
36 if not self
.channels
.is_valid(arg
):
37 self
.msg(channel
, "I'm not in @b%s@b." % arg
)
39 self
.auth
.request(sender
, arg
, 'nonews')
41 def private_channel_mass(self
, manager
, opts
, arg
, channel
, sender
):
42 if not self
.channels
.is_valid(arg
):
43 self
.msg(channel
, "I'm not in @b%s@b." % arg
)
45 self
.auth
.request(sender
, arg
, 'chanmass')
47 def private_channel_nomass(self
, manager
, opts
, arg
, channel
, sender
):
48 if not self
.channels
.is_valid(arg
):
49 self
.msg(channel
, "I'm not in @b%s@b." % arg
)
51 self
.auth
.request(sender
, arg
, 'nochanmass')
53 def private_user_mass(self
, manager
, opts
, arg
, channel
, sender
):
54 self
.auth
.request(sender
, sender
, 'usermass')
56 def private_user_nomass(self
, manager
, opts
, arg
, channel
, sender
):
57 self
.auth
.request(sender
, sender
, 'nousermass')
59 def private_help(self
, manager
, opts
, arg
, channel
, sender
):
63 message
= manager
.get_help()
65 message
= manager
.get_help(command
)
68 message
= ['%s is not a valid command.' % arg
]
71 self
.msg(channel
, line
)
73 class PrivateCommandManager(CommandManager
):
77 def get_invalid(self
):
78 return 'Invalid message. Say help for a list of valid messages.'
80 def get_commands(self
):
82 'request': (private_channel_request
, ARG_YES|ARG_OFFLINE
, 'requests a channel (must be founder)', [], '#channel'),
83 'remove': (private_channel_remove
, ARG_YES|ARG_OFFLINE
, 'removes a channel (must be founder)', [], '#channel'),
84 'news': (private_channel_news
, ARG_YES|ARG_OFFLINE
, 'enables news broadcasting on the channel (must be founder)', [], '#channel'),
85 'nonews': (private_channel_nonews
, ARG_YES|ARG_OFFLINE
, 'disables news broadcasting on the channel (must be founder)', [], '#channel'),
86 'chanmass': (private_channel_mass
, ARG_YES|ARG_OFFLINE
, 'enables mass highlighting on the channel (must be founder)', [], '#channel'),
87 'nochanmass': (private_channel_nomass
, ARG_YES|ARG_OFFLINE
, 'disables mass highlighting on the channel (must be founder)', [], '#channel'),
88 'usermass': (private_user_mass
, ARG_NO|ARG_OFFLINE
, 'includes your nick in mass highlights', []),
89 'nousermass': (private_user_nomass
, ARG_NO|ARG_OFFLINE
, 'exclude your nick from mass highlights', []),
92 'help': (private_help
, ARG_OPT
, 'displays help text', []),