Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added channel specific values + argument to setvar() and getvar(). Ad…

…ded setchvar() and getchvar() as aliases for channel specific variables.
  • Loading branch information...
commit a531265f47526f1ad62e12d0977763ef1379f097 1 parent 75a1bb0
@omnidan authored
Showing with 18 additions and 2 deletions.
  1. +18 −2 irc.py
View
20 irc.py
@@ -229,8 +229,19 @@ def db_findone(self, collection, dict):
def db_find(self, collection, dict):
return collection.find(dict)
- def getvar(self, variable):
+ def getchvar(self, channel, variable):
+ self.getvar(variable, channel)
+
+ def setchvar(self, channel, variable, content):
+ self.setvar(variable, content, channel)
+
+ def getvar(self, variable, channel=None):
variable = variable.lower()
+ variable = re.sub("[^0-9a-z_]", "", variable)
+ if channel != None:
+ channel = channel.lower()
+ channel = re.sub("[^0-9a-z\#-]", "", channel)
+ variable = channel + "." + variable
col = self.db_open("iforcebot_vars")
rawresult = self.db_findone(col, {"var": variable})
if rawresult != None:
@@ -238,8 +249,13 @@ def getvar(self, variable):
else:
return None
- def setvar(self, variable, content):
+ def setvar(self, variable, content, channel=None):
variable = variable.lower()
+ variable = re.sub("[^0-9a-z_]", "", variable)
+ if channel != None:
+ channel = channel.lower()
+ channel = re.sub("[^0-9a-z\#-]", "", channel)
+ variable = channel + "." + variable
col = self.db_open("iforcebot_vars")
self.db_update(col, {"var": variable}, {"$set": {"con": content}})
Please sign in to comment.
Something went wrong with that request. Please try again.