diff options
author | mrDoctorWho <mrdoctorwho@gmail.com> | 2015-03-20 11:30:44 +0300 |
---|---|---|
committer | mrDoctorWho <mrdoctorwho@gmail.com> | 2015-03-20 11:30:44 +0300 |
commit | 16fc44d9389b38edc8bb8bd4580ff2df0893e2cb (patch) | |
tree | 94997598ce69ef90c7760a43bb05167d4437fc24 /modules/mod_iq_disco.py | |
parent | fc54c21eb862ac59f135883e3ce5539ec7cb6a36 (diff) |
Added a possibility to change vk4xmpp-monitor address
Added new events: 08 and 09 (see plugin .example.py for more information)
Replaced code “with Database(...” by runDatabaseQuery()
Added last_used timestamp for groupchats
Added inactive groupchats exterminator
Groupchats are now kept in the database, so nothing will be missed or messed
As groupchats are now in the database, the function that was calling for Daleks to exterminate a chat was completely rewritten, so now Daleks don't have to exterminate any VK administrator to find out the groupchat owner
TransportFeatures and UserFeatures was cleared in the kernel and now they must be filled by modules and extensions
Added "force_vk_date" to user's settings to force VK timestamp for messages
A brand new Module Loader that allows you easy to load, unload and reload any module
A bit of optimizations for html unescape
As there are new events: 08 and 09, the Watcher now is a plugin
Kilobytes replaced by Megabytes in stats
Fixed exec command, now it execs the code in the main globals()
Diffstat (limited to 'modules/mod_iq_disco.py')
-rw-r--r-- | modules/mod_iq_disco.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/modules/mod_iq_disco.py b/modules/mod_iq_disco.py index b59a0a8..c07d4c1 100644 --- a/modules/mod_iq_disco.py +++ b/modules/mod_iq_disco.py @@ -74,11 +74,7 @@ def disco_handler(cl, iq): sender(cl, result) -def getUsersList(): - with Database(DatabaseFile) as db: - db("select jid from users") - result = db.fetchall() - return result +getUsersList = lambda: runDatabaseQuery("select jid from users", many=True) def deleteUsers(jids): @@ -96,6 +92,9 @@ def sendGlobalMessage(text): def checkAPIToken(token): + """ + Checks API token, returns dict or error + """ vk = VK() try: auth = vk.auth(token, True, False) @@ -112,6 +111,11 @@ def checkAPIToken(token): def dictToDataForm(_dict, _fields=None): + """ + Makes a buildForm()-compatible dict from a random key-value dict + converts boolean types to a boolean field, + converts multiline string to a text-multi field and so on. + """ _fields = _fields or [] for key, value in _dict.iteritems(): result = {"var": key, "value": value} @@ -119,13 +123,12 @@ def dictToDataForm(_dict, _fields=None): type = "text-signle" elif isinstance(value, bool): - print key, value type = "boolean" value = utils.normalizeValue(value) - print key,value elif isinstance(value, dict): dictToDataForm(value, _fields) + elif isinstance(value, str): type = "text-single" if "\n" in value: @@ -269,12 +272,20 @@ def commands_handler(cl, iq): def load(): + TransportFeatures.add(xmpp.NS_COMMANDS) + TransportFeatures.add(xmpp.NS_DISCO_INFO) + TransportFeatures.add(xmpp.NS_DISCO_ITEMS) + TransportFeatures.add(xmpp.NS_DATA) Component.RegisterHandler("iq", disco_handler, "get", xmpp.NS_DISCO_INFO) Component.RegisterHandler("iq", disco_handler, "get", xmpp.NS_DISCO_ITEMS) Component.RegisterHandler("iq", commands_handler, "set") def unload(): + TransportFeatures.remove(xmpp.NS_COMMANDS) + TransportFeatures.remove(xmpp.NS_DISCO_INFO) + TransportFeatures.remove(xmpp.NS_DISCO_ITEMS) + TransportFeatures.remove(xmpp.NS_DATA) Component.UnregisterHandler("iq", disco_handler, "get", xmpp.NS_DISCO_INFO) Component.UnregisterHandler("iq", disco_handler, "get", xmpp.NS_DISCO_ITEMS) Component.UnregisterHandler("iq", commands_handler, "set")
\ No newline at end of file |