This repository has been archived by the owner on Dec 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saloonmute.py
114 lines (94 loc) · 4.01 KB
/
saloonmute.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
# -*- coding utf-8
# Copyright (C) 2018 Chris2000SP <[email protected]>
# Copyright (C) 2013 Stefan Hacker <[email protected]>
# All rights reserved
#
# saloonmute.py
#
## Global Variable ##
varMuteAktive=False
varUserSessionToMute=[]
varUserChannelToMute=[]
otherusers=[]
from mumo_module import (commaSeperatedIntegers,
MumoModule)
#from threading import Timer
import re
import cgi
class saloonmute(MumoModule):
default_config = {'saloonmute':(
('servers', commaSeperatedIntegers, []),
),
}
def __init__(self, name, manager, configuration = None):
MumoModule.__init__(self, name, manager, configuration)
self.murmur = manager.getMurmurModule()
self.action_info = manager.getUniqueAction()
self.action_muteAktive = manager.getUniqueAction()
self.watchdog = None
def connected(self):
manager = self.manager()
log = self.log()
log.debug("Register for Server callbacks")
servers = self.cfg().saloonmute.servers
if not servers:
servers = manager.SERVERS_ALL
manager.subscribeServerCallbacks(self, servers)
try:
meta = manager.getMeta();
connServers = meta.getBootedServers();
userCount = 0
for serv in connServers:
userlist = serv.getUsers()
for user in userlist:
#otherusers.append(userlist[user].name)
entry = "%i-%s" % (serv.id(), userlist[user].name)
log.debug("User chan: %s - Server: %i - %s", userlist[user].name, serv.id(), entry)
userCount = userCount + 1
log.debug("Successfully took snapshot of user positions into memory for %i" % userCount)
except:
log.debug("Could not load user data into memory. Will track moving forward.")
def disconnected(self): pass
def isTalking(self, server, action, user, target):
assert action == self.action_info
self.log().info(user.name + " wants info on " + str(user));
#server.sendMessage(user.session,
# "<small><pre>" + cgi.escape(str(user)) + "</pre></small>")
#while len(varUserSessionToMute) < 0:
#userlist
#if varMuteAktive:
# do something
def muteAktive(self, server, action, user, target):
assert action == self.action_muteAktive
self.log().info(user.name +
" will surpressed if some one talks in Channel");
varUserSessionToMute.append(user.session)
self.log().debug("varUserSessionToMute <= " + str(user.session));
varUserChannelToMute.append(user.channel)
self.log().debug("varUserChannelToMute <= " + str(user.channel));
def userConnected(self, server, user, context = None):
self.log().info("Adding menu entries for " + user.name)
manager = self.manager()
manager.addContextMenuEntry(
server,
user,
self.action_info,
"Info",
self.isTalking,
self.murmur.ContextUser
)
manager.addContextMenuEntry(
server,
user,
self.action_muteAktive,
"Saloon Mute on Speak",
self.muteAktive,
self.murmur.ContextUser
)
def userDisconnected(self, server, state, context = None): pass
def userStateChanged(self, server, state, context = None): pass
def userTextMessage(self, server, user, message, current = None): pass
def channelCreated(self, server, state, context = None): pass
def channelRemoved(self, server, state, context = None): pass
def channelStateChanged(self, server, state, context = None): pass