-
Notifications
You must be signed in to change notification settings - Fork 2
/
message_queue.py
executable file
·65 lines (57 loc) · 2.89 KB
/
message_queue.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim: set expandtab tabstop=4 shiftwidth=4 :
# message_queue.py - A module of the Exocortex XMPP Bridge that implements the
# message queue as a global so the other classes can all see it.
#
# This is part of the Exocortex Halo project
# (https://github.com/virtadpt/exocortex-halo/).
# v5.0 - Reworking for Python 3.
# v4.0 - Refacted bot to break major functional parts out into separate modules.
# v3.0 - Rewriting to use SleekXMPP, because I'm tired of XMPPpy's lack of
# documentation. The code is much more sleek, if nothing else.
# - Refactored the core message processing method to split out the
# common stuff (online help and status reports) into helper methods.
# v2.2 - Added a universal API rail '/replies' so that bots can send replies
# to their user over XMPP by hitting their configured XMPP bridge over
# HTTP.
# v2.1.1 - Started pulling 'search' out of text because this bot is used for
# much more than just web searches.
# v2.1 - Working on the "goes into a coma and pegs the CPU problem" by adding
# XEP-0199 client-to-server pings to keep the server alive.
# - Added online help to the command parser.
# v2.0 - Rewrote using xmpppy (http://xmpppy.sourceforge.net/) because it's
# more lightweight than SleekXMPP and hopefully has fewer interactions.
# Also, if I need to, I should be able to drop nbXMPP
# (https://python-nbxmpp.gajim.org/) in with minimal code modification.
# - Added some code that lets the bot interact more with its owner to
# provide feedback. I got tired of having to read the logs to see what
# was going on, okay?
# - Renamed a bunch of stuff because I tore out the old XMPPBot and wrote
# a new class from scratch. It made it easier to keep track of in my
# head... until I did so, in fact, I had a hard time rewriting this
# bot.
# v1.1 - Switched out OptionParser in favor of argparse.
# - Refactored the code to make a little more sense. argparse helped a
# lot with that.
# - Reworked logging a little.
# - Declared variables at the tops of everything for maintainability.
# Having to deal with a phantom variable that pops out of nowhere is
# kind of annoying.
# - Setting SleekXMPP to "block=True" makes it easier to kill from the
# command line.
# - Set the default loglevel to INFO.
# v1.0 - Initial release.
# TODO:
# -
# By: The Doctor <drwho at virtadpt dot net>
# 0x807B17C1 / 7960 1CDC 85C9 0B63 8D9F DD89 3BD8 FF2B 807B 17C1
# License: GPLv3
# This hash table's keys are the names of agents, the associated values are
# lists which implement the message queues.
message_queue = {}
# Add the message queue so this bot's agents can send replies.
message_queue['replies'] = []
if "__name__" == "__main__":
print("No self tests yet.")
sys.exit(0)