libbot 56__tar.gz → 70__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. libbot-70/PKG-INFO +202 -0
  2. libbot-70/README.rst +186 -0
  3. libbot-70/bin/bot +106 -0
  4. libbot-70/bin/botd +90 -0
  5. libbot-70/bot/modules/__init__.py +31 -0
  6. {libbot-56 → libbot-70}/bot/modules/cmd.py +2 -2
  7. libbot-70/bot/modules/err.py +22 -0
  8. {libbot-56 → libbot-70}/bot/modules/irc.py +64 -196
  9. {libbot-56 → libbot-70}/bot/modules/log.py +4 -3
  10. libbot-70/bot/modules/mod.py +13 -0
  11. libbot-70/bot/modules/mre.py +25 -0
  12. libbot-70/bot/modules/pwd.py +19 -0
  13. {libbot-56 → libbot-70}/bot/modules/rss.py +15 -11
  14. {libbot-56 → libbot-70}/bot/modules/tdo.py +10 -4
  15. {libbot-56 → libbot-70}/bot/modules/thr.py +3 -2
  16. libbot-70/bot/modules/tmr.py +77 -0
  17. libbot-70/libbot.egg-info/PKG-INFO +202 -0
  18. {libbot-56 → libbot-70}/libbot.egg-info/SOURCES.txt +5 -16
  19. libbot-70/libbot.egg-info/requires.txt +2 -0
  20. {libbot-56 → libbot-70}/pyproject.toml +7 -2
  21. libbot-56/PKG-INFO +0 -201
  22. libbot-56/README.rst +0 -185
  23. libbot-56/bin/bot +0 -149
  24. libbot-56/bot/__init__.py +0 -73
  25. libbot-56/bot/brokers.py +0 -54
  26. libbot-56/bot/censors.py +0 -41
  27. libbot-56/bot/command.py +0 -65
  28. libbot-56/bot/excepts.py +0 -61
  29. libbot-56/bot/message.py +0 -49
  30. libbot-56/bot/modules/__init__.py +0 -9
  31. libbot-56/bot/modules/err.py +0 -29
  32. libbot-56/bot/modules/fnd.py +0 -41
  33. libbot-56/bot/modules/mbx.py +0 -149
  34. libbot-56/bot/modules/mod.py +0 -19
  35. libbot-56/bot/modules/req.py +0 -83
  36. libbot-56/bot/modules/shp.py +0 -51
  37. libbot-56/bot/objects.py +0 -224
  38. libbot-56/bot/parsers.py +0 -70
  39. libbot-56/bot/repeats.py +0 -67
  40. libbot-56/bot/runtime.py +0 -129
  41. libbot-56/bot/storage.py +0 -283
  42. libbot-56/bot/threads.py +0 -99
  43. libbot-56/libbot.egg-info/PKG-INFO +0 -201
  44. {libbot-56 → libbot-70}/libbot.egg-info/dependency_links.txt +0 -0
  45. {libbot-56 → libbot-70}/libbot.egg-info/top_level.txt +0 -0
  46. {libbot-56 → libbot-70}/libbot.egg-info/zip-safe +0 -0
  47. {libbot-56 → libbot-70}/setup.cfg +0 -0
  48. {libbot-56 → libbot-70}/setup.py +0 -0
libbot-70/PKG-INFO ADDED
@@ -0,0 +1,202 @@
1
+ Metadata-Version: 2.1
2
+ Name: libbot
3
+ Version: 70
4
+ Summary: the python3 bot namespace
5
+ Author-email: libbot <libbotx@gmail.com>
6
+ License: Public Domain
7
+ Project-URL: home, https://pypi.org/project/libbot
8
+ Project-URL: bugs, https://github.com/botlibx/libbot/issues
9
+ Project-URL: source, https://github.com/botlibx/libbot
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: License :: Public Domain
12
+ Classifier: Operating System :: Unix
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Topic :: Utilities
15
+ Description-Content-Type: text/x-rst
16
+
17
+ NAME
18
+
19
+ ::
20
+
21
+ LIBBOT - the python3 bot namespave
22
+
23
+ SYNOPSIS
24
+
25
+ ::
26
+
27
+ bot <cmd> [key=val]
28
+ bot <cmd> [key==val]
29
+ bot [-c] [-v] [-d]
30
+
31
+
32
+ DESCRIPTION
33
+
34
+ ::
35
+
36
+
37
+
38
+ LIBBOT is a python3 library implementing the 'bot' package. It
39
+ provides all the tools to program a bot, such as disk perisistence
40
+ for configuration files, event handler to handle the client/server
41
+ connection, code to introspect modules for commands, deferred
42
+ exception handling to not crash on an error, a parser to parse
43
+ commandline options and values, etc.
44
+
45
+ LIBBOT provides a demo bot, it can connect to IRC, fetch and
46
+ display RSS feeds, take todo notes, keep a shopping list
47
+ and log text. You can also copy/paste the service file and run
48
+ it under systemd for 24/7 presence in a IRC channel.
49
+
50
+ LIBBOT is a contribution back to society and is Public Domain.
51
+
52
+
53
+ INSTALL
54
+
55
+
56
+ ::
57
+
58
+ $ pipx install libbot
59
+
60
+
61
+ USAGE
62
+
63
+ ::
64
+
65
+ without any argument the bot does nothing
66
+
67
+ $ bot
68
+ $
69
+
70
+ see list of commands
71
+
72
+ $ bot cmd
73
+ cmd,err,mod,req,thr,ver
74
+
75
+ list of modules
76
+
77
+ $ bot mod
78
+ cmd,err,fnd,irc,log,mod,req,rss,tdo,thr
79
+
80
+ use mod=<name1,name2> to load additional
81
+ modules
82
+
83
+ $ bot cfg mod=irc
84
+
85
+ start a console
86
+
87
+ $ bot -c mod=irc,rss
88
+ >
89
+
90
+ use -v for verbose
91
+
92
+ $ bot -cv mod=irc
93
+ BOT started CV started Sat Dec 2 17:53:24 2023
94
+ >
95
+
96
+ start daemon
97
+
98
+ $ botd
99
+ $
100
+
101
+
102
+ CONFIGURATION
103
+
104
+
105
+ ::
106
+
107
+ irc
108
+
109
+ $ bot cfg server=<server>
110
+ $ bot cfg channel=<channel>
111
+ $ bot cfg nick=<nick>
112
+
113
+ sasl
114
+
115
+ $ bot pwd <nsvnick> <nspass>
116
+ $ bot cfg password=<frompwd>
117
+
118
+ rss
119
+
120
+ $ bot rss <url>
121
+ $ bot dpl <url> <item1,item2>
122
+ $ bot rem <url>
123
+ $ bot nme <url< <name>
124
+
125
+
126
+ COMMANDS
127
+
128
+
129
+ ::
130
+
131
+ cmd - commands
132
+ cfg - irc configuration
133
+ dlt - remove a user
134
+ dpl - sets display items
135
+ fnd - find objects
136
+ log - log some text
137
+ met - add a user
138
+ mre - displays cached output
139
+ pwd - sasl nickserv name/pass
140
+ rem - removes a rss feed
141
+ req - reconsider
142
+ rss - add a feed
143
+ thr - show the running threads
144
+
145
+
146
+ SYSTEMD
147
+
148
+
149
+ ::
150
+
151
+ replace "<user>" with the user running pipx
152
+
153
+
154
+ [Unit]
155
+ Description=24/7 channel daemon
156
+ Requires=network.target
157
+ After=network.target
158
+
159
+ [Service]
160
+ Type=simple
161
+ User=<user>
162
+ Group=<user>
163
+ WorkingDirectory=/home/<user>/.bot
164
+ ExecStart=/home/<user>/.local/pipx/venvs/libbot/bin/botd
165
+ RemainAfterExit=yes
166
+
167
+ [Install]
168
+ WantedBy=multi-user.target
169
+
170
+
171
+ then run this
172
+
173
+ $ mkdir ~/.bot
174
+ $ sudo systemctl enable botd --now
175
+
176
+ default channel/server is #bot on localhost
177
+
178
+
179
+ FILES
180
+
181
+ ::
182
+
183
+ ~/.bot
184
+ ~/.local/bin/bot
185
+ ~/.local/bin/botd
186
+ ~/.local/pipx/venvs/libbot/
187
+
188
+
189
+ AUTHOR
190
+
191
+
192
+ ::
193
+
194
+ libbotx <libbotx@gmail.com>
195
+
196
+
197
+ COPYRIGHT
198
+
199
+
200
+ ::
201
+
202
+ LIBBOT is Public Domain.
libbot-70/README.rst ADDED
@@ -0,0 +1,186 @@
1
+ NAME
2
+
3
+ ::
4
+
5
+ LIBBOT - the python3 bot namespave
6
+
7
+ SYNOPSIS
8
+
9
+ ::
10
+
11
+ bot <cmd> [key=val]
12
+ bot <cmd> [key==val]
13
+ bot [-c] [-v] [-d]
14
+
15
+
16
+ DESCRIPTION
17
+
18
+ ::
19
+
20
+
21
+
22
+ LIBBOT is a python3 library implementing the 'bot' package. It
23
+ provides all the tools to program a bot, such as disk perisistence
24
+ for configuration files, event handler to handle the client/server
25
+ connection, code to introspect modules for commands, deferred
26
+ exception handling to not crash on an error, a parser to parse
27
+ commandline options and values, etc.
28
+
29
+ LIBBOT provides a demo bot, it can connect to IRC, fetch and
30
+ display RSS feeds, take todo notes, keep a shopping list
31
+ and log text. You can also copy/paste the service file and run
32
+ it under systemd for 24/7 presence in a IRC channel.
33
+
34
+ LIBBOT is a contribution back to society and is Public Domain.
35
+
36
+
37
+ INSTALL
38
+
39
+
40
+ ::
41
+
42
+ $ pipx install libbot
43
+
44
+
45
+ USAGE
46
+
47
+ ::
48
+
49
+ without any argument the bot does nothing
50
+
51
+ $ bot
52
+ $
53
+
54
+ see list of commands
55
+
56
+ $ bot cmd
57
+ cmd,err,mod,req,thr,ver
58
+
59
+ list of modules
60
+
61
+ $ bot mod
62
+ cmd,err,fnd,irc,log,mod,req,rss,tdo,thr
63
+
64
+ use mod=<name1,name2> to load additional
65
+ modules
66
+
67
+ $ bot cfg mod=irc
68
+
69
+ start a console
70
+
71
+ $ bot -c mod=irc,rss
72
+ >
73
+
74
+ use -v for verbose
75
+
76
+ $ bot -cv mod=irc
77
+ BOT started CV started Sat Dec 2 17:53:24 2023
78
+ >
79
+
80
+ start daemon
81
+
82
+ $ botd
83
+ $
84
+
85
+
86
+ CONFIGURATION
87
+
88
+
89
+ ::
90
+
91
+ irc
92
+
93
+ $ bot cfg server=<server>
94
+ $ bot cfg channel=<channel>
95
+ $ bot cfg nick=<nick>
96
+
97
+ sasl
98
+
99
+ $ bot pwd <nsvnick> <nspass>
100
+ $ bot cfg password=<frompwd>
101
+
102
+ rss
103
+
104
+ $ bot rss <url>
105
+ $ bot dpl <url> <item1,item2>
106
+ $ bot rem <url>
107
+ $ bot nme <url< <name>
108
+
109
+
110
+ COMMANDS
111
+
112
+
113
+ ::
114
+
115
+ cmd - commands
116
+ cfg - irc configuration
117
+ dlt - remove a user
118
+ dpl - sets display items
119
+ fnd - find objects
120
+ log - log some text
121
+ met - add a user
122
+ mre - displays cached output
123
+ pwd - sasl nickserv name/pass
124
+ rem - removes a rss feed
125
+ req - reconsider
126
+ rss - add a feed
127
+ thr - show the running threads
128
+
129
+
130
+ SYSTEMD
131
+
132
+
133
+ ::
134
+
135
+ replace "<user>" with the user running pipx
136
+
137
+
138
+ [Unit]
139
+ Description=24/7 channel daemon
140
+ Requires=network.target
141
+ After=network.target
142
+
143
+ [Service]
144
+ Type=simple
145
+ User=<user>
146
+ Group=<user>
147
+ WorkingDirectory=/home/<user>/.bot
148
+ ExecStart=/home/<user>/.local/pipx/venvs/libbot/bin/botd
149
+ RemainAfterExit=yes
150
+
151
+ [Install]
152
+ WantedBy=multi-user.target
153
+
154
+
155
+ then run this
156
+
157
+ $ mkdir ~/.bot
158
+ $ sudo systemctl enable botd --now
159
+
160
+ default channel/server is #bot on localhost
161
+
162
+
163
+ FILES
164
+
165
+ ::
166
+
167
+ ~/.bot
168
+ ~/.local/bin/bot
169
+ ~/.local/bin/botd
170
+ ~/.local/pipx/venvs/libbot/
171
+
172
+
173
+ AUTHOR
174
+
175
+
176
+ ::
177
+
178
+ libbotx <libbotx@gmail.com>
179
+
180
+
181
+ COPYRIGHT
182
+
183
+
184
+ ::
185
+
186
+ LIBBOT is Public Domain.
libbot-70/bin/bot ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env python3
2
+ # This file is placed in the Public Domain.
3
+ #
4
+ # pylint: disable=C,R,W0201,W0212,W0105,W0613,W0406,E0102,W0611,W0718,W0125
5
+
6
+
7
+ "runtime"
8
+
9
+
10
+ import getpass
11
+ import os
12
+ import sys
13
+ import termios
14
+ import time
15
+
16
+
17
+ sys.path.insert(0, os.getcwd())
18
+
19
+
20
+ from obj import Default, Object
21
+ from prg import Client, Error, Event, Storage
22
+ from prg import cmnd, debug, forever, parse_command, scan, spl
23
+ from bot import modules
24
+
25
+
26
+ Cfg = Default()
27
+ Cfg.mod = "cmd,err,irc,mod,mre,pwd,rss,thr"
28
+ Cfg.name = "bot"
29
+ Cfg.version = "70"
30
+ Cfg.wd = os.path.expanduser(f"~/.{Cfg.name}")
31
+ Cfg.pidfile = os.path.join(Cfg.wd, f"{Cfg.name}.pid")
32
+ Cfg.user = getpass.getuser()
33
+
34
+
35
+ Storage.wd = Cfg.wd
36
+
37
+
38
+ class Console(Client):
39
+
40
+ def announce(self, txt):
41
+ if "v" in Cfg.opts:
42
+ self.say("", txt)
43
+
44
+ def poll(self) -> Event:
45
+ evt = Event()
46
+ evt.orig = object.__repr__(self)
47
+ evt.txt = input("> ")
48
+ evt.type = "command"
49
+ return evt
50
+
51
+ def say(self, channel, txt):
52
+ txt = txt.encode('utf-8', 'replace').decode()
53
+ print(txt)
54
+
55
+
56
+ def wrap(func) -> None:
57
+ old2 = None
58
+ try:
59
+ old2 = termios.tcgetattr(sys.stdin.fileno())
60
+ except termios.error:
61
+ pass
62
+ try:
63
+ func()
64
+ except (KeyboardInterrupt, EOFError):
65
+ print("")
66
+ finally:
67
+ if old2:
68
+ termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, old2)
69
+
70
+
71
+ "runtime"
72
+
73
+
74
+ if os.path.exists("mods"):
75
+ import mods
76
+ else:
77
+ mods = None
78
+
79
+
80
+ def main():
81
+ Storage.skel()
82
+ parse_command(Cfg, " ".join(sys.argv[1:]))
83
+ if "a" in Cfg.opts:
84
+ Cfg.mod = ",".join(modules.__dir__())
85
+ if "m" in Cfg.opts:
86
+ Cfg.mod += "," + ",".join(mods.__dir__())
87
+ if "v" in Cfg.opts:
88
+ dte = time.ctime(time.time()).replace(" ", " ")
89
+ debug(f"{Cfg.name.upper()} started {Cfg.opts.upper()} started {dte}")
90
+ csl = Console()
91
+ if "c" in Cfg.opts:
92
+ scan(modules, Cfg.mod, True, True)
93
+ if "m" in Cfg.opts:
94
+ scan(mods, Cfg.mod, True, True)
95
+ csl.start()
96
+ forever()
97
+ if Cfg.otxt:
98
+ scan(modules, Cfg.mod)
99
+ if "m" in Cfg.opts:
100
+ scan(mods, Cfg.mod)
101
+ return cmnd(Cfg.otxt)
102
+
103
+
104
+ if __name__ == "__main__":
105
+ wrap(main)
106
+ Error.show()
libbot-70/bin/botd ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env python3
2
+ # This file is placed in the Public Domain.
3
+ #
4
+ # pylint: disable=C,R,W0201,W0212,W0105,W0613,W0406,E0102,W0611,W0718,W0125
5
+
6
+
7
+ "runtime"
8
+
9
+
10
+ import getpass
11
+ import os
12
+ import pwd
13
+ import sys
14
+ import termios
15
+ import time
16
+
17
+
18
+ sys.path.insert(0, os.getcwd())
19
+
20
+
21
+ from obj import Default, Object
22
+ from prg import Client, Error, Event, Storage
23
+ from prg import cmnd, debug, forever, parse_command, scan, spl
24
+ from bot import modules
25
+
26
+
27
+ from prg.storage import cdir
28
+
29
+
30
+ Cfg = Default()
31
+ Cfg.mod = "cmd,err,irc,log,mod,mre,pwd,rss,thr"
32
+ Cfg.name = "bot"
33
+ Cfg.version = "70"
34
+ Cfg.wd = os.path.expanduser(f"~/.{Cfg.name}")
35
+ Cfg.pidfile = os.path.join(Cfg.wd, f"{Cfg.name}.pid")
36
+ Cfg.user = getpass.getuser()
37
+
38
+
39
+ Storage.wd = Cfg.wd
40
+ moddir = os.path.join(Storage.wd, "mods")
41
+
42
+
43
+ if os.path.exists(moddir):
44
+ sys.path.insert(0, os.path.dirname(moddir))
45
+ import mods
46
+ else:
47
+ mods = None
48
+
49
+
50
+ def daemon(pidfile, verbose=False):
51
+ pid = os.fork()
52
+ if pid != 0:
53
+ os._exit(0)
54
+ os.setsid()
55
+ pid2 = os.fork()
56
+ if pid2 != 0:
57
+ os._exit(0)
58
+ if not verbose:
59
+ with open('/dev/null', 'r', encoding="utf-8") as sis:
60
+ os.dup2(sis.fileno(), sys.stdin.fileno())
61
+ with open('/dev/null', 'a+', encoding="utf-8") as sos:
62
+ os.dup2(sos.fileno(), sys.stdout.fileno())
63
+ with open('/dev/null', 'a+', encoding="utf-8") as ses:
64
+ os.dup2(ses.fileno(), sys.stderr.fileno())
65
+ os.umask(0)
66
+ os.chdir("/")
67
+ if os.path.exists(pidfile):
68
+ os.unlink(pidfile)
69
+ cdir(os.path.dirname(pidfile))
70
+ with open(pidfile, "w", encoding="utf-8") as fds:
71
+ fds.write(str(os.getpid()))
72
+
73
+
74
+ def privileges(username):
75
+ pwnam = pwd.getpwnam(username)
76
+ os.setgid(pwnam.pw_gid)
77
+ os.setuid(pwnam.pw_uid)
78
+
79
+
80
+ def main():
81
+ Storage.skel()
82
+ daemon(Cfg.pidfile)
83
+ privileges(Cfg.user)
84
+ scan(modules, Cfg.mod, True, True)
85
+ if mods:
86
+ scan(mods, Cfg.mod, True, True)
87
+ forever()
88
+
89
+
90
+ main()
@@ -0,0 +1,31 @@
1
+ # This file is placed in the Public Domain.
2
+ #
3
+ #
4
+
5
+
6
+ "pre-import"
7
+
8
+
9
+ import sys
10
+
11
+
12
+ from . import cmd, err, irc, log, mod, mre, pwd, rss, tdo, thr, tmr
13
+
14
+
15
+ def __dir__():
16
+ return (
17
+ 'cmd',
18
+ 'err',
19
+ 'irc',
20
+ 'log',
21
+ 'mod',
22
+ 'mre',
23
+ 'pwd',
24
+ 'rss',
25
+ 'tdo',
26
+ 'thr',
27
+ 'tmr',
28
+ )
29
+
30
+
31
+ __all__ = __dir__()
@@ -6,8 +6,8 @@
6
6
  "list of commands"
7
7
 
8
8
 
9
- from .. import Commands
9
+ from prg import Command
10
10
 
11
11
 
12
12
  def cmd(event):
13
- event.reply(",".join(sorted(Commands.cmds)))
13
+ event.reply(",".join(sorted(Command.cmds)))
@@ -0,0 +1,22 @@
1
+ # This file is placed in the Public Domain.
2
+ #
3
+ # pylint: disable=C0116,W0105,E0402,E0611
4
+
5
+
6
+ "status of bots"
7
+
8
+
9
+ from prg import Error, Fleet
10
+
11
+
12
+ def err(event):
13
+ nmr = 0
14
+ for bot in Fleet.objs:
15
+ if 'state' in dir(bot):
16
+ event.reply(str(bot.state))
17
+ nmr += 1
18
+ event.reply(f"status: {nmr} errors: {len(Error.errors)}")
19
+ for exc in Error.errors:
20
+ txt = Error.format(exc)
21
+ for line in txt.split():
22
+ event.reply(line)