-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyawaynick.py
30 lines (21 loc) · 964 Bytes
/
pyawaynick.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import znc
class pyawaynick(znc.Module):
module_types = [znc.CModInfo.UserModule]
def OnClientLogin(self):
self.GetNetwork().PutIRC("NICK " + self.GetNetwork().GetNick())
def OnClientDisconnect(self):
if not self.GetNetwork().IsUserAttached():
if "away_nick" in self.nv:
self.GetNetwork().PutIRC("NICK " + self.nv["away_nick"])
def OnModCommand(self, sCommand):
sCommand = sCommand.split(" ")
sParams = sCommand[1:]
sCommand = sCommand[0].lower()
if sCommand == "set":
self.nv["away_nick"] = sParams[0]
self.PutModule("Your away nick is now set to: '" + sParams[0] + "'")
elif sCommand == "show":
if not "away_nick" in self.nv:
self.PutModule("You have no away nick set - use the SET command")
else:
self.PutModule("Your away nick is set to: '" + self.nv["away_nick"] + "'")