diff options
author | nico <nico@magicbroccoli.de> | 2018-11-06 23:43:11 +0100 |
---|---|---|
committer | nico <nico@magicbroccoli.de> | 2018-11-06 23:43:11 +0100 |
commit | 0c313565f2b649366f7382dc1b3f28a3e80f4ffc (patch) | |
tree | 953d5ccff11b3954794d3ed713239e16b3be6b19 /classes/version.py | |
parent | 559ab280ca705bca200823a0493308b10aba1dd4 (diff) |
simplification and major rework
* updated gitignore file
* partly reworked servercontact implementation
* complete rework of uptime, version
* part rework of xep requests
+ added more comments to xep requests
+ added opt_arg to version, xep and contact
* complete rework of validate function
* updated HandleError function
* part rework of StaticStrings function
+ implemented data dictionary to hold all data in main bot
+ added message_ids
* complete rework of queue building and deduplication
Diffstat (limited to 'classes/version.py')
-rw-r--r-- | classes/version.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/classes/version.py b/classes/version.py new file mode 100644 index 0000000..1e9ef7e --- /dev/null +++ b/classes/version.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + + +# XEP-0072: Server Version +class Version: + """ + process and format a version query + """ + def __init__(self): + # init all necessary variables + self.software_version = None + self.target, self.opt_arg = None, None + + def format_result(self): + # list of all possible opt_arg + possible_opt_args = ["version", "os", "name"] + + name = self.software_version['name'] + version = self.software_version['version'] + os = self.software_version['os'] + + # if opt_arg is given member of possible_opt_args list return that element + if self.opt_arg in possible_opt_args: + text = "%s: %s" % (self.opt_arg, self.software_version[self.opt_arg]) + + # otherwise return full version string + else: + text = "%s is running %s version %s on %s" % (self.target, name, version, os) + + return text + + def format(self, query, target, opt_arg): + self.software_version = query['software_version'] + + self.target = target + self.opt_arg = opt_arg + + reply = self.format_result() + return reply |