Compare commits

...

202 Commits
v1.2 ... v1.4

Author SHA1 Message Date
SpudGunMan
abeb28c9cc Update golfsim.py 2024-10-02 23:20:59 -07:00
SpudGunMan
2325f74581 Update simulator.py 2024-10-02 15:13:28 -07:00
SpudGunMan
e75ef3e44d Update simulator.py 2024-10-02 14:51:46 -07:00
SpudGunMan
6431b45769 Update mesh_bot.py 2024-10-02 10:39:48 -07:00
SpudGunMan
7dfcbb619f Update simulator.py 2024-10-02 01:39:07 -07:00
SpudGunMan
051b58ca6f bleEnhance 2024-10-01 17:17:50 -07:00
SpudGunMan
5777b39c22 Update mmind.py 2024-10-01 14:11:38 -07:00
SpudGunMan
eb4f135698 🪣 2024-10-01 11:16:26 -07:00
SpudGunMan
3bcb04ece7 ️HighScore 2024-10-01 00:17:52 -07:00
SpudGunMan
e42aca875f fixStroke 2024-09-30 23:49:56 -07:00
SpudGunMan
28915ab848 Update golfsim.py 2024-09-30 23:25:38 -07:00
SpudGunMan
0fe491871d Update golfsim.py 2024-09-30 23:25:12 -07:00
SpudGunMan
6fc6a483a8 Update golfsim.py 2024-09-30 23:06:27 -07:00
SpudGunMan
13236880b5 Update golfsim.py 2024-09-30 22:56:37 -07:00
SpudGunMan
9461719039 Update golfsim.py 2024-09-30 22:50:31 -07:00
SpudGunMan
63163cc4c1 ️Caddy
added a caddy
2024-09-30 22:28:59 -07:00
SpudGunMan
5cdf159bc1 add TZ local
resolves https://github.com/SpudGunMan/meshing-around/issues/72
2024-09-30 21:17:03 -07:00
SpudGunMan
47a9981fdf enhance
resolve https://github.com/SpudGunMan/meshing-around/issues/73

new game play hazards
2024-09-30 21:16:00 -07:00
SpudGunMan
f85bdb7d02 clubOrder🥪
resolve https://github.com/SpudGunMan/meshing-around/issues/75
2024-09-30 16:56:41 -07:00
SpudGunMan
7796d03e21 Update mmind.py 2024-09-30 16:53:33 -07:00
SpudGunMan
90094c082a Update mmind.py
resolved https://github.com/SpudGunMan/meshing-around/issues/74
2024-09-30 16:53:11 -07:00
SpudGunMan
2b695e2f2e Update wx_meteo.py 2024-09-30 16:43:10 -07:00
SpudGunMan
2e05f3ef64 Update wx_meteo.py
reference
https://github.com/open-meteo/open-meteo/issues/287

and also https://github.com/SpudGunMan/meshing-around/issues/71
2024-09-30 16:39:25 -07:00
SpudGunMan
316f1efd08 Update Dockerfile 2024-09-30 16:18:37 -07:00
SpudGunMan
4678a63955 enhance
expert mode and saves score
2024-09-30 12:56:04 -07:00
SpudGunMan
8584454d5d Update README.md 2024-09-30 09:15:28 -07:00
SpudGunMan
2c6cf76a10 Update mmind.py 2024-09-30 03:17:15 -07:00
SpudGunMan
cd3226df21 enhance 2024-09-30 03:04:38 -07:00
SpudGunMan
4bcc6ef1f2 Update mesh_bot.py 2024-09-30 02:57:46 -07:00
SpudGunMan
77e56c25ae golfEnhance 2024-09-30 02:51:54 -07:00
SpudGunMan
e7b363612a timePlay 2024-09-30 02:44:46 -07:00
SpudGunMan
a217c61ba1 LateNightDoubleFeature
* golfsim
* masterMind

New Games!
2024-09-30 02:37:08 -07:00
SpudGunMan
e7b4fe44c8 Update simulator.py 2024-09-29 21:39:05 -07:00
SpudGunMan
f8cc580b99 Update mesh_bot.py 2024-09-29 15:01:45 -07:00
SpudGunMan
03057b3263 Update mesh_bot.py 2024-09-29 12:55:41 -07:00
SpudGunMan
452b9b7c67 Update mesh_bot.py 2024-09-29 12:50:57 -07:00
SpudGunMan
5ae16d0adc Update videopoker.py 2024-09-29 12:49:14 -07:00
SpudGunMan
5ed135c023 Update README.md 2024-09-28 14:05:03 -07:00
SpudGunMan
d425298cd9 Update dopewar.py 2024-09-28 12:17:16 -07:00
SpudGunMan
786815d073 Update dopewar.py 2024-09-28 12:04:17 -07:00
SpudGunMan
54cad92a3f enhance 💊 game display 2024-09-28 12:03:08 -07:00
SpudGunMan
54e21f4644 Update mesh_bot.py 2024-09-28 00:53:19 -07:00
SpudGunMan
3c76f177cd Update simulator.py 2024-09-28 00:46:47 -07:00
SpudGunMan
aa05c62d94 fix🍋hs 2024-09-28 00:45:57 -07:00
SpudGunMan
3f16158e27 Update mesh_bot.py 2024-09-28 00:28:59 -07:00
SpudGunMan
6f2824512d highscoreEnhance 2024-09-28 00:27:45 -07:00
SpudGunMan
723b67f886 🥔 2024-09-28 00:14:27 -07:00
SpudGunMan
008d55e63b Update mesh_bot.py 2024-09-28 00:12:33 -07:00
SpudGunMan
79885454ab fixLongStandingIssues
fix long time bugs of 21 and the suggestions
2024-09-27 23:47:14 -07:00
SpudGunMan
ba21723bdc fix BlackJackwin! 2024-09-27 23:38:40 -07:00
SpudGunMan
c36c4918a8 Update mesh_bot.py 2024-09-27 22:33:07 -07:00
SpudGunMan
853147518d space 2024-09-27 22:32:46 -07:00
SpudGunMan
2f19d86c95 💩
: get it
2024-09-27 22:17:07 -07:00
SpudGunMan
39bdabffcb Update blackjack.py 2024-09-27 21:57:40 -07:00
SpudGunMan
a7bdaedfe1 Update blackjack.py 2024-09-27 21:57:22 -07:00
SpudGunMan
1c6106081f Weight2Wait
add weight to the wait for responses. as the comment says this is a specific use case for the Q: blah blah A: 2. I am seeing a hang up this is to help keep delivery high.
2024-09-27 21:48:13 -07:00
SpudGunMan
8ab6cded2e 🥝 2024-09-27 21:14:06 -07:00
SpudGunMan
ff63bb959a Update mesh_bot.py 2024-09-27 20:55:50 -07:00
SpudGunMan
6c79bb1ff0 Update mesh_bot.py 2024-09-27 20:50:36 -07:00
SpudGunMan
ce73336c0c Update mesh_bot.py 2024-09-27 20:49:05 -07:00
SpudGunMan
248977c5b5 enhance
* replay hand with H or R
2024-09-27 18:06:11 -07:00
SpudGunMan
77a6e63210 howRandom 2024-09-27 17:39:55 -07:00
SpudGunMan
6f6fb35177 IgnoreDefaultChannel
ability to fully ignore the default channel if wanted, default is false
2024-09-27 17:37:34 -07:00
SpudGunMan
9db565cb4f changeLogPath
tidy up this mess
2024-09-27 17:18:35 -07:00
SpudGunMan
2a254a7fab fixNewTable.pkl 2024-09-27 01:06:15 -07:00
SpudGunMan
15e76ab029 fixCasinoGamesForGood? 2024-09-27 00:57:57 -07:00
SpudGunMan
66b95cdaa0 casinoHighScores
I got a really good score its a shame it was wasted
2024-09-27 00:25:17 -07:00
SpudGunMan
32ea93cb88 Update mesh_bot.py 2024-09-26 22:11:42 -07:00
SpudGunMan
22a2a64861 Update bbstools.py 2024-09-26 21:08:29 -07:00
SpudGunMan
d841fdf02c bbsinfo 2024-09-26 21:03:57 -07:00
Kelly
9421f09ded Merge pull request #69 from SpudGunMan/lab
messages from !hex ID
2024-09-26 20:56:35 -07:00
SpudGunMan
b4af552fb9 Update mesh_bot.py 2024-09-26 20:55:32 -07:00
Kelly
69dfb17460 Merge pull request #68 from Nestpebble/main
Add in BBS-DM via node hex ID
2024-09-26 20:47:09 -07:00
SpudGunMan
4703750c27 Update videopoker.py 2024-09-26 20:45:49 -07:00
Nestpebble
40caf99939 Merge branch 'SpudGunMan:main' into main 2024-09-27 03:43:45 +01:00
Nestpebble
df5f648b26 try and round off adding an interpreter to the bbs DM 2024-09-27 03:30:21 +01:00
Nestpebble
55472bbbc0 try this 2024-09-27 03:12:40 +01:00
Nestpebble
f23c4e2b6a sdf 2024-09-27 02:29:58 +01:00
Nestpebble
0b101d662e trying to simplify nodeid entry... 2024-09-27 02:26:55 +01:00
SpudGunMan
a7f07afc14 consolidateTime 2024-09-26 18:13:58 -07:00
SpudGunMan
2715021898 Update README.md 2024-09-26 18:02:52 -07:00
SpudGunMan
e8fa0036e2 Update mesh_bot.py 2024-09-26 17:57:05 -07:00
SpudGunMan
f628a5e7ef Update mesh_bot.py 2024-09-26 17:56:56 -07:00
SpudGunMan
95e6bc120e Update mesh_bot.py 2024-09-26 17:32:34 -07:00
SpudGunMan
0e35c891c4 Update mesh_bot.py 2024-09-26 17:29:54 -07:00
SpudGunMan
b7a3e7014c Update mesh_bot.py 2024-09-26 17:26:42 -07:00
Nestpebble
0c1c587bc7 strip ! from tonode, cos its copied by default on
the android app.
2024-09-27 01:26:01 +01:00
SpudGunMan
a0a2c60e63 Update mesh_bot.py 2024-09-26 17:25:29 -07:00
SpudGunMan
45c912a0d6 Update mesh_bot.py 2024-09-26 17:19:50 -07:00
Kelly
39945f161d Merge pull request #66 from Nestpebble/main
Help messages, condensed ping
2024-09-26 17:15:46 -07:00
Nestpebble
ed958302bd sdfsdfsdf 2024-09-26 23:07:19 +01:00
Nestpebble
477f2141d7 sdfsdf 2024-09-26 22:57:20 +01:00
Nestpebble
d321a958f0 more tidying 2024-09-26 22:50:45 +01:00
Nestpebble
d14f1df823 tweak some help messages 2024-09-26 22:49:20 +01:00
Nestpebble
f7e3b9f6c7 Merge branch 'SpudGunMan:main' into main 2024-09-26 22:25:20 +01:00
Nestpebble
cd3ac201f8 general tidy up, done 2024-09-26 22:23:15 +01:00
Nestpebble
ceef493b01 dfgdf 2024-09-26 22:17:38 +01:00
Nestpebble
480a75e30c Merge branch 'main' of https://github.com/Nestpebble/meshing-around 2024-09-26 22:17:02 +01:00
Nestpebble
d8cc953fe7 Removed handle_testing & handle_ack,
now in handle_ping
2024-09-26 22:16:17 +01:00
Nestpebble
0baec88321 Removed handle_testing & handle_ack,
now in handle_ping
2024-09-26 22:12:10 +01:00
Nestpebble
74bd3f681f dssdf 2024-09-26 22:05:31 +01:00
Nestpebble
713b750f4a sdfsd 2024-09-26 21:56:41 +01:00
Nestpebble
11eee911ca sdfsdf 2024-09-26 21:54:47 +01:00
Nestpebble
b288aaea90 szadsad 2024-09-26 21:32:25 +01:00
Nestpebble
7acc018fd2 sdfsd 2024-09-26 21:30:35 +01:00
Nestpebble
7aba1096f9 szd 2024-09-26 21:20:30 +01:00
Nestpebble
0be7202144 dsfrg 2024-09-26 21:18:49 +01:00
Nestpebble
83a5db74e5 Merge branch 'main' of https://github.com/Nestpebble/meshing-around 2024-09-26 21:16:20 +01:00
Nestpebble
8dc4371beb deghdfgdrfgdf 2024-09-26 21:16:08 +01:00
Nestpebble
e5045a0984 drfgdf 2024-09-26 21:14:29 +01:00
Nestpebble
2c9b37a0cc sdfsdfsdf 2024-09-26 21:09:53 +01:00
Nestpebble
b608482220 typo 2024-09-26 21:05:11 +01:00
Nestpebble
9290fac899 I think I consolidated the pings... 2024-09-26 21:03:43 +01:00
Nestpebble
d7901ee575 sdfsdfsd 2024-09-26 18:57:55 +01:00
Nestpebble
7eb33a5aef sdfsdfsdf 2024-09-26 18:56:36 +01:00
Nestpebble
c5dc103ac0 compressed ping response 2024-09-26 15:28:48 +01:00
Nestpebble
c90172a862 fixed it 2024-09-26 14:31:58 +01:00
Nestpebble
8540786c2c added help text to history 2024-09-26 14:28:49 +01:00
Nestpebble
7aeb8e851d Update mesh_bot.py 2024-09-26 14:24:27 +01:00
Nestpebble
2f207dc3d9 Update mesh_bot.py 2024-09-26 14:18:25 +01:00
Nestpebble
7e2be73962 Update mesh_bot.py 2024-09-26 14:17:29 +01:00
SpudGunMan
e2a87eb945 ReticulatingSplines
Reticulating some Splines and other items which need full Reticulation.
2024-09-26 00:18:07 -07:00
SpudGunMan
4b79c6304f Update install.sh 2024-09-25 23:00:02 -07:00
SpudGunMan
22f63e1056 cleanup 2024-09-25 22:56:01 -07:00
SpudGunMan
bf1613ba66 Update mesh_bot.py 2024-09-25 22:40:26 -07:00
SpudGunMan
38e04db0cb Update install.sh 2024-09-25 22:38:45 -07:00
SpudGunMan
08cc3034a2 Update install.sh 2024-09-25 22:37:13 -07:00
SpudGunMan
a0eb176b6e Update install.sh 2024-09-25 22:33:32 -07:00
SpudGunMan
a43774b33f Update install.sh 2024-09-25 22:32:01 -07:00
SpudGunMan
8369b4d205 Update install.sh 2024-09-25 22:26:37 -07:00
SpudGunMan
87e51cf9f9 Update install.sh 2024-09-25 22:24:08 -07:00
SpudGunMan
8a8fb79fde Update install.sh 2024-09-25 22:19:36 -07:00
SpudGunMan
1dc4cf36b1 Update install.sh 2024-09-25 22:16:13 -07:00
SpudGunMan
75cf43e02a enhance 2024-09-25 21:58:34 -07:00
SpudGunMan
dd8357453b serviceFix 2024-09-25 21:43:04 -07:00
SpudGunMan
e9b273a62c Update system.py 2024-09-25 21:23:12 -07:00
SpudGunMan
ebebd0fda6 Update install.sh 2024-09-25 21:09:29 -07:00
SpudGunMan
3e06902b07 Update config.template 2024-09-25 21:09:11 -07:00
SpudGunMan
a874b42c41 Update install.sh 2024-09-25 19:27:30 -07:00
Nestpebble
f6215d3563 Tidied up, added a few help messages. 2024-09-26 02:02:26 +01:00
SpudGunMan
4fad58f7fe Update system.py 2024-09-25 17:12:05 -07:00
SpudGunMan
276e4c3d09 ? trap 2024-09-25 16:38:27 -07:00
SpudGunMan
8aef4d605b Update README.md 2024-09-25 15:42:59 -07:00
SpudGunMan
962c891baa fixes 2024-09-25 15:40:50 -07:00
Kelly
eb596ea901 Merge pull request #65 from SpudGunMan/lab
enhance CMD Logic with isDM
2024-09-25 14:30:20 -07:00
SpudGunMan
e708ec9adc Update mesh_bot.py 2024-09-25 14:27:39 -07:00
Kelly
c631a083ea Merge pull request #64 from Nestpebble/main
Nestpebble isDM
2024-09-25 13:36:29 -07:00
Nestpebble
169ea8c233 Update mesh_bot.py 2024-09-25 13:12:08 +01:00
Nestpebble
241e2258e8 Update mesh_bot.py 2024-09-25 13:04:08 +01:00
Nestpebble
5d2d6bc5fb utilise isDM to split responses 2024-09-25 12:53:42 +01:00
Nestpebble
c7ef22f5c2 Update mesh_bot.py 2024-09-25 12:41:52 +01:00
Nestpebble
3ec89decf0 Update mesh_bot.py 2024-09-25 12:36:39 +01:00
SpudGunMan
2693f47ed5 Update locationdata.py 2024-09-24 20:01:05 -07:00
SpudGunMan
496a13e0e0 Update mesh_bot.py 2024-09-24 19:33:17 -07:00
SpudGunMan
71ef416dbb Update videopoker.py 2024-09-24 19:32:48 -07:00
SpudGunMan
5bc80c8677 Update dopewar.py 2024-09-24 19:32:44 -07:00
SpudGunMan
8c300f467c Update blackjack.py 2024-09-24 19:32:39 -07:00
SpudGunMan
78b3bf1475 Update bbstools.py 2024-09-24 19:32:32 -07:00
SpudGunMan
ce74f910a7 Update pong_bot.py 2024-09-24 19:32:26 -07:00
SpudGunMan
ece531249e Update bbsdb_admin.py 2024-09-24 19:32:21 -07:00
Nestpebble
5052e2510e Update mesh_bot.py 2024-09-25 01:33:21 +01:00
Nestpebble
b8f8f80499 Update mesh_bot.py 2024-09-25 01:28:47 +01:00
Nestpebble
a13d98e32b Update mesh_bot.py 2024-09-25 01:19:18 +01:00
SpudGunMan
94996dcec8 fixHours 2024-09-24 12:31:44 -07:00
SpudGunMan
4b8ce30df8 sleep1
the short responces of a single letter cause quick turn around
2024-09-24 12:28:51 -07:00
SpudGunMan
485a37e9b5 Update mesh_bot.py 2024-09-23 22:58:36 -07:00
SpudGunMan
b41adb12f7 Update blackjack.py 2024-09-23 22:54:46 -07:00
SpudGunMan
a9cd443bdd Update mesh_bot.py 2024-09-23 21:03:05 -07:00
SpudGunMan
92b9df718f gameplayEnhance 2024-09-23 20:03:34 -07:00
SpudGunMan
a6a4f91d83 Update mesh_bot.py 2024-09-23 19:43:23 -07:00
SpudGunMan
0fb2c498f4 Update mesh_bot.py 2024-09-23 19:43:00 -07:00
SpudGunMan
d87e70f7ee Update mesh_bot.py 2024-09-23 19:35:22 -07:00
SpudGunMan
bee8bae0ae Revert "fixing"
This reverts commit d5ef277121.
2024-09-23 19:29:14 -07:00
SpudGunMan
d5ef277121 fixing 2024-09-23 19:24:14 -07:00
SpudGunMan
dfc8e6c108 Update mesh_bot.py 2024-09-23 19:20:51 -07:00
SpudGunMan
9100aee91f Update mesh_bot.py 2024-09-23 19:10:38 -07:00
SpudGunMan
c94cc92d1c Update mesh_bot.py 2024-09-23 17:41:44 -07:00
SpudGunMan
a41f5e3aca Update blackjack.py 2024-09-23 17:03:43 -07:00
SpudGunMan
cc2d15de0d Update mesh_bot.py 2024-09-23 17:03:40 -07:00
SpudGunMan
39e08aedae borked 2024-09-23 14:43:55 -07:00
SpudGunMan
fe8730fb1f Update mesh_bot.py 2024-09-23 14:42:48 -07:00
SpudGunMan
aac3ac8947 Update mesh_bot.py 2024-09-23 14:42:22 -07:00
SpudGunMan
1acc908bb8 Update mesh_bot.py 2024-09-23 14:33:48 -07:00
SpudGunMan
47ed98a5e1 Update mesh_bot.py 2024-09-23 14:23:07 -07:00
SpudGunMan
103034d1b8 enhance
line 1000
2024-09-23 14:16:26 -07:00
SpudGunMan
608714d00a more enhancing 2024-09-23 13:35:23 -07:00
SpudGunMan
575c287860 unoReverse! 2024-09-23 13:24:45 -07:00
SpudGunMan
820470bef7 tuning 2024-09-23 12:18:23 -07:00
SpudGunMan
ea000ef56c Update mesh_bot.py 2024-09-23 11:22:27 -07:00
SpudGunMan
793b8f8495 Update mesh_bot.py 2024-09-23 01:46:01 -07:00
SpudGunMan
373eee3024 Update mesh_bot.py 2024-09-23 01:43:35 -07:00
SpudGunMan
194273635e kiss 2024-09-23 01:31:24 -07:00
SpudGunMan
0972d7d89d fix 2024-09-23 00:22:58 -07:00
SpudGunMan
d1415f9d86 enhance 2024-09-22 23:56:27 -07:00
SpudGunMan
b3ff3bb406 enhanceHistory
enhance.. enhance...
2024-09-22 23:38:55 -07:00
SpudGunMan
1efce62a8a Update mesh_bot.py 2024-09-22 22:47:28 -07:00
SpudGunMan
442f2ff927 command history feature
fun idea from discord bitflip for command history and showing last time someone used the bot
2024-09-22 22:23:31 -07:00
SpudGunMan
84cefa1be8 Update mesh_bot.py 2024-09-22 18:28:54 -07:00
SpudGunMan
45e9c1eccb Update mesh_bot.py 2024-09-22 18:28:21 -07:00
SpudGunMan
e7e2c9604e 2.5firmware PKI enhance 2024-09-22 18:15:24 -07:00
SpudGunMan
edaf6875ef Update pong_bot.py 2024-09-22 17:45:42 -07:00
SpudGunMan
e7976a0a88 packetDebug 2024-09-22 17:45:33 -07:00
24 changed files with 1740 additions and 504 deletions

View File

@@ -1,8 +1,14 @@
FROM python:3.10-slim
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y gettext && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y gettext tzdata locales && rm -rf /var/lib/apt/lists/*
# Set the locale default to en_US.UTF-8
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
ENV TZ="America/Los_Angeles"
WORKDIR /app
COPY . /app

View File

@@ -12,7 +12,7 @@ The bot is also capable of using dual radio/nodes, so you can monitor two networ
Look up data using wiki results, or interact with [Ollama](https://ollama.com) LLM AI see the [OllamaDocs](https://github.com/ollama/ollama/tree/main/docs) If Ollama is enabled you can DM the bot directly. The default model for mesh-bot which is currently `gemma2:2b`
The bot will report on anyone who is getting close to the configured lat/long, if in a remote location.
The bot will report on anyone who is getting close to the configured lat/long, if in a remote location. For example having the bot in your camp site alerts when members arive back at camp.
Store and forward-like message re-play with `messages`, and there is a repeater module for dual radio bots to cross post messages. Messages are also logged locally to disk.
@@ -34,6 +34,7 @@ Any messages that are over 160 characters are chunked into 160 message bytes to
- `bbsread` read a message example use: `bbsread #1`
- `bbspost` post a message to public board or send a DM example use: `bbspost $subject #message, or bbspost @nodeNumber #message or bbspost @nodeShortName #message`
- `bbsdelete` delete a message example use: `bbsdelete #4`
- `bbsinfo` Stats on BBS delivery and messages (sysop)
- Other functions
- `whereami` returns the address of location of sender if known
- `whoami` returns some details of the node asking
@@ -46,12 +47,15 @@ Any messages that are over 160 characters are chunked into 160 message bytes to
- `messages` Replay the last messages heard, like Store and Forward
- `motd` or to set the message `motd $New Message Of the day`
- `lheard` returns the last 5 heard nodes with SNR, can also use `sitrep`
- `history` returns the last commands ran by user(s)
- `cmd` returns the list of commands (the help message)
- Games
- `lemonstand` plays the classic Lemonade Stand Finance game via DM
- `dopewars` plays the classic drug trader game via DM
- `blackjack` BlackJack
- `videopoker` Video Poker
- Games - via DM
- `lemonstand` plays the classic Lemonade Stand Finance
- `dopewars` plays the classic drug trader
- `blackjack` BlackJack, Casino 21
- `videopoker` Video Poker, basic 5 card hold
- `mastermind` Classic code-breaking game
- `golfsim` Golf Simulator, 9 Hole
## pong_bot.sh
Stripped-down bot, mostly around for archive purposes. The mesh-bot enhanced modules can be disabled by config to disable features.
@@ -121,6 +125,13 @@ enabled = False
DadJokes = False
StoreForward = False
```
History command is like a linix terminal, shows the last commands the user ran and the `lheard` reflects last users on the bot.
```
# history command
enableCmdHistory = True
# command history ignore list ex: 2813308004,4258675309
lheardCmdIgnoreNodes =
```
Sentry Bot detects anyone coming close to the bot-node
```
# detect anyone close to the bot
@@ -184,20 +195,6 @@ googleSearchResults = 3 # number of google search results to include in the cont
llm_history_limit = 6 # limit the history to 3 messages (come in pairs) more results = more compute time
```
Logging messages to disk or Syslog to disk uses the python native logging function. Take a look at the [/modules/log.py](/modules/log.py) you can set the file logger for syslog to INFO for example to not log DEBUG messages to file log, or modify the stdOut level.
```
[general]
# logging to file of the non Bot messages
LogMessagesToFile = True
# Logging of system messages to file
SyslogToFile = True
```
Example to log to disk only INFO and higher (ignore DEBUG)
```
*log.py
file_handler.setLevel(logging.INFO) # DEBUG used by default for system logs to disk example here shows INFO
```
The Scheduler is enabled in the [settings.py](modules/settings.py) by setting `scheduler_enabled = True` the actions and settings are via code only at this time. see [mesh_bot.py](mesh_bot.py) around line [425](https://github.com/SpudGunMan/meshing-around/blob/22983133ee4db3df34f66699f565e506de296197/mesh_bot.py#L425-L435) to edit schedule its most flexible to edit raw code right now. See https://schedule.readthedocs.io/en/stable/ for more.
```
@@ -256,7 +253,9 @@ Games Ported from..
- https://github.com/Reconfirefly/drugwars
- https://github.com/Himan10/BlackJack
- https://github.com/devtronvarma/Video-Poker-Terminal-Game
- https://github.com/pwdkramer/pythonMastermind/
- https://github.com/danfriedman30/pythongame (Golf)
GitHub user Nestpebble, for new ideas and enhancments, mrpatrick1991 For Docker configs, PiDiBi looking at test functions and other suggestions like wxc, CPU use, and alerting ideas
Discord and Mesh user Cisien, and github Hailo1999, for testing and ideas! Lots of individuals on the Meshtastic discord who have tossed out ideas and tested code!
Discord and Mesh user Cisien, bitflip, and github Hailo1999, for testing and feature ideas! Lots of individuals on the Meshtastic discord who have tossed out ideas and tested code!

View File

@@ -25,8 +25,10 @@ port = /dev/ttyUSB0
[general]
# if False will respond on all channels but the default channel
respond_by_dm_only = True
# defaultChannel is the meshtastic default public channel
# defaultChannel is the meshtastic default public channel, e.g. LongFast
defaultChannel = 0
# ignoreDefaultChannel, the bot will ignore the default channel set above
ignoreDefaultChannel = False
# motd is reset to this value on boot
motd = Thanks for using MeshBOT! Have a good day!
welcome_message = MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd
@@ -45,6 +47,10 @@ ollama = False
# StoreForward Enabled and Limits
StoreForward = True
StoreLimit = 3
# history command
enableCmdHistory = True
# command history ignore list ex: 2813308004,4258675309
lheardCmdIgnoreNodes =
# 24 hour clock
zuluTime = False
# wait time for URL requests
@@ -60,6 +66,8 @@ dopeWars = True
lemonade = True
blackjack = True
videopoker = True
mastermind = True
golfsim = True
[sentry]
# detect anyone close to the bot
@@ -121,6 +129,6 @@ signalCycleLimit = 5
# delay in seconds for response to avoid message collision
responseDelay = 0.7
# delay in seconds for splits in messages to avoid message collision
splitDelay = 0.7
splitDelay = 0.0
# message chunk size for sending at high success rate
MESSAGE_CHUNK_SIZE = 160

View File

@@ -1,54 +0,0 @@
# Load the bbs messages from the database file to screen for admin functions
import pickle # pip install pickle
# load the bbs messages from the database file
try:
with open('../bbsdb.pkl', 'rb') as f:
bbs_messages = pickle.load(f)
except:
try:
with open('bbsdb.pkl', 'rb') as f:
bbs_messages = pickle.load(f)
except:
print ("\nSystem: bbsdb.pkl not found")
try:
with open('../bbsdm.pkl', 'rb') as f:
bbs_dm = pickle.load(f)
except:
try:
with open('bbsdm.pkl', 'rb') as f:
bbs_dm = pickle.load(f)
except:
print ("\nSystem: bbsdm.pkl not found")
# Game HS tables
try:
with open('../lemonade_hs.pkl', 'rb') as f:
lemon_score = pickle.load(f)
except:
try:
with open('lemonade_hs.pkl', 'rb') as f:
lemon_score = pickle.load(f)
except:
print ("\nSystem: lemonade_hs.pkl not found")
try:
with open('../dopewar_hs.pkl', 'rb') as f:
dopewar_score = pickle.load(f)
except:
try:
with open('dopewar_hs.pkl', 'rb') as f:
dopewar_score = pickle.load(f)
except:
print ("\nSystem: dopewar_hs.pkl not found")
print ("\nSystem: bbs_messages")
print (bbs_messages)
print ("\nSystem: bbs_dm")
print (bbs_dm)
print ("Game HS tables")
print (f"lemon:{lemon_score}")
print (f"dopewar:{dopewar_score}")

100
etc/db_admin.py Normal file
View File

@@ -0,0 +1,100 @@
# Load the bbs messages from the database file to screen for admin functions
import pickle # pip install pickle
# load the bbs messages from the database file
try:
with open('../bbsdb.pkl', 'rb') as f:
bbs_messages = pickle.load(f)
except Exception as e:
try:
with open('bbsdb.pkl', 'rb') as f:
bbs_messages = pickle.load(f)
except Exception as e:
bbs_messages = "System: bbsdb.pkl not found"
try:
with open('../bbsdm.pkl', 'rb') as f:
bbs_dm = pickle.load(f)
except Exception as e:
try:
with open('bbsdm.pkl', 'rb') as f:
bbs_dm = pickle.load(f)
except Exception as e:
bbs_dm = "System: bbsdm.pkl not found"
# Game HS tables
try:
with open('../lemonade_hs.pkl', 'rb') as f:
lemon_score = pickle.load(f)
except Exception as e:
try:
with open('lemonade_hs.pkl', 'rb') as f:
lemon_score = pickle.load(f)
except Exception as e:
lemon_score = "System: lemonade_hs.pkl not found"
try:
with open('../dopewar_hs.pkl', 'rb') as f:
dopewar_score = pickle.load(f)
except Exception as e:
try:
with open('dopewar_hs.pkl', 'rb') as f:
dopewar_score = pickle.load(f)
except Exception as e:
dopewar_score = "System: dopewar_hs.pkl not found"
try:
with open('../blackjack_hs.pkl', 'rb') as f:
blackjack_score = pickle.load(f)
except Exception as e:
try:
with open('blackjack_hs.pkl', 'rb') as f:
blackjack_score = pickle.load(f)
except Exception as e:
blackjack_score = "System: blackjack_hs.pkl not found"
try:
with open('../videopoker_hs.pkl', 'rb') as f:
videopoker_score = pickle.load(f)
except Exception as e:
try:
with open('videopoker_hs.pkl', 'rb') as f:
videopoker_score = pickle.load(f)
except Exception as e:
videopoker_score = "System: videopoker_hs.pkl not found"
try:
with open('../mmind_hs.pkl', 'rb') as f:
mmind_score = pickle.load(f)
except Exception as e:
try:
with open('mmind_hs.pkl', 'rb') as f:
mmind_score = pickle.load(f)
except Exception as e:
mmind_score = "System: mmind_hs.pkl not found"
try:
with open('../golfsim_hs.pkl', 'rb') as f:
golfsim_score = pickle.load(f)
except Exception as e:
try:
with open('golfsim_hs.pkl', 'rb') as f:
golfsim_score = pickle.load(f)
except Exception as e:
golfsim_score = "System: golfsim_hs.pkl not found"
print ("\n Meshing-Around Database Admin Tool\n")
print ("System: bbs_messages")
print (bbs_messages)
print ("\nSystem: bbs_dm")
print (bbs_dm)
print (f"\n\nGame HS tables\n")
print (f"lemon:{lemon_score}")
print (f"dopewar:{dopewar_score}")
print (f"blackjack:{blackjack_score}")
print (f"videopoker:{videopoker_score}")
print (f"mmind:{mmind_score}")
print (f"golfsim:{golfsim_score}")
print ("\n")

View File

@@ -7,8 +7,12 @@ Description=MESH-BOT
After=network.target
[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/dir/
ExecStart=/usr/bin/bash /dir/launch.sh mesh
ExecStart=python3 mesh_bot.py
ExecStop=pkill -f mesh_bot.py
# Disable Python's buffering of STDOUT and STDERR, so that output from the
# service shows up immediately in systemd's logs

View File

@@ -7,8 +7,12 @@ Description=PONG-BOT
After=network.target
[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/dir/
ExecStart=/usr/bin/bash /dir/launch.sh pong
ExecStart=python3 pong_bot.py
ExecStop=pkill -f pong_bot.py
# Disable Python's buffering of STDOUT and STDERR, so that output from the
# service shows up immediately in systemd's logs

View File

@@ -8,6 +8,7 @@ import random
projectName = "example_handler" # name of _handler function to match the function name under test
randomNode = False # Set to True to use random node IDs
# bot.py Simulated functions
def get_NodeID():
nodeList = [4258675309, 1212121212, 1234567890, 9876543210]
if randomNode:
@@ -15,6 +16,10 @@ def get_NodeID():
else:
nodeID = nodeList[0]
return nodeID
def get_name_from_number(nodeID, length='short', interface=1):
# return random name for nodeID
names = ["Max","Molly","Jake","Kelly"]
return names[nodeID % len(names)]
# # end Initialization of the tool
# # Function to handle, or the project in test
@@ -37,7 +42,7 @@ if __name__ == '__main__': # represents the bot's main loop
nodeInt = 1 # represents the device/node number
logger.info(f"System: Meshing-Around Simulator Starting for {projectName}")
nodeID = get_NodeID() # assign a nodeID
projectResponse = globals()[projectName](nodeID, " ") # Call the project handler under test
projectResponse = globals()[projectName](0, 0, " ") # Call the project handler under test
while True: # represents the onReceive() loop in the bot.py
projectResponse = ""
responseLength = 0
@@ -46,7 +51,7 @@ if __name__ == '__main__': # represents the bot's main loop
packet = input(f"CLIENT {nodeID} INPUT: " ) # Emulate the client input
if packet != "":
#try:
projectResponse = globals()[projectName](nodeID, packet) # Call the project handler under test
projectResponse = globals()[projectName](nodeID, deviceID=nodeInt, message=packet) # Call the project handler under test
# except Exception as e:
# logger.error(f"System: Handler: {e}")
# projectResponse = "Error in handler"

View File

@@ -2,14 +2,20 @@
# install.sh
cd "$(dirname "$0")"
program_path=$(pwd)
cp etc/pong_bot.tmp etc/pong_bot.service
cp etc/mesh_bot.tmp etc/mesh_bot.service
printf "\nMeshing Around Installer\n"
printf "\nThis script will install the Meshing Around bot and its dependencies works best in debian/ubuntu\n"
printf "\nChecking for dependencies\n"
# add user to groups for serial access
printf "\nAdding user to dialout and tty groups for serial access\n"
sudo usermod -a -G dialout $USER
sudo usermod -a -G tty $USER
sudo usermod -a -G bluetooth $USER
# check for pip
if ! command -v pip &> /dev/null
@@ -33,21 +39,12 @@ printf "\nConfig file generated\n"
# set virtual environment and install dependencies
printf "\nMeshing Around Installer\n"
#check if python3 has venv module
if ! python3 -m venv --help &> /dev/null
then
printf "Python3 venv module not found, please install python3-venv with your OS\n"
else
printf "Python3 venv module found\n"
fi
echo "Do you want to install the bot in a virtual environment? (y/n)"
read venv
if [ $venv == "y" ]; then
# set virtual environment
if ! python3 -m venv --help &> /dev/null
then
if ! python3 -m venv --help &> /dev/null; then
printf "Python3 venv module not found, please install python3-venv with your OS\n"
exit 1
else
@@ -55,13 +52,28 @@ if [ $venv == "y" ]; then
python3 -m venv venv
source venv/bin/activate
# install dependencies
pip install -U -r requirements.txt
#check if python3 has venv module
if [ -f venv/bin/activate ]; then
printf "\nFpund virtual environment for python\n"
else
sudo apt-get install python3-venv
printf "\nPython3 venv module not found, please install python3-venv with your OS if not already done. re-run the script\n"
exxt 1
fi
# config service files for virtual environment
replace="s|python3 mesh_bot.py|/usr/bin/bash launch.sh mesh|g"
sed -i "$replace" etc/mesh_bot.service
replace="s|python3 pong_bot.py|/usr/bin/bash launch.sh pong|g"
sed -i "$replace" etc/pong_bot.service
# install dependencies
pip install -U -r requirements.txt
fi
else
printf "\nSkipping virtual environment...\n"
# install dependencies
printf "Are you on Raspberry Pi?\nshould we add --break-system-packages to the pip install command? (y/n)"
printf "Are you on Raspberry Pi(debian/ubuntu)?\nshould we add --break-system-packages to the pip install command? (y/n)"
read rpi
if [ $rpi == "y" ]; then
pip install -U -r requirements.txt --break-system-packages
@@ -74,33 +86,39 @@ printf "\n\n"
echo "Which bot do you want to install as a service? Pong Mesh or None? (pong/mesh/n)"
read bot
#set the correct path in the service file
program_path=$(pwd)
cp etc/pong_bot.tmp etc/pong_bot.service
cp etc/mesh_bot.tmp etc/mesh_bot.service
# set the correct path in the service file
replace="s|/dir/|$program_path/|g"
sed -i $replace etc/pong_bot.service
sed -i $replace etc/mesh_bot.service
# set the correct user in the service file?
whoami=$(whoami)
replace="s|User=pi|User=$whoami|g"
sed -i $replace etc/pong_bot.service
sed -i $replace etc/mesh_bot.service
replace="s|Group=pi|Group=$whoami|g"
sed -i $replace etc/pong_bot.service
sed -i $replace etc/mesh_bot.service
sudo systemctl daemon-reload
printf "\n service files updated\n"
# ask if emoji font should be installed for linux
echo "Do you want to install the emoji font for debian linux? (y/n)"
echo "Do you want to install the emoji font for debian/ubuntu linux? (y/n)"
read emoji
if [ $emoji == "y" ]; then
sudo apt-get install fonts-noto-color-emoji
sudo apt-get install -y fonts-noto-color-emoji
echo "Emoji font installed!, reboot to load the font"
fi
if [ $bot == "pong" ]; then
# install service for pong bot
sudo cp etc/pong_bot.service /etc/systemd/system/
exit 0
sudo systemctl enable pong_bot.service
fi
if [ $bot == "mesh" ]; then
# install service for mesh bot
sudo cp etc/mesh_bot.service /etc/systemd/system/
exit 0
sudo systemctl enable mesh_bot.service
fi
if [ $bot == "n" ]; then
@@ -124,11 +142,14 @@ if [ $ollama == "y" ]; then
echo "Do you want to install the Gemma2:2b components? (y/n)"
read gemma
if [ $gemma == "y" ]; then
olamma pull gemma2:2b
ollama pull gemma2:2b
fi
fi
echo "Good time to reboot? (y/n)"
read reboot
if [ $reboot == "y" ]; then
sudo reboot
fi
printf "\nGoodbye!"
exit 0

15
logs/README.md Normal file
View File

@@ -0,0 +1,15 @@
Logs will collect here.
Logging messages to disk or Syslog to disk uses the python native logging function. Take a look at the [/modules/log.py](/modules/log.py) you can set the file logger for syslog to INFO for example to not log DEBUG messages to file log, or modify the stdOut level.
```
[general]
# logging to file of the non Bot messages
LogMessagesToFile = True
# Logging of system messages to file
SyslogToFile = True
```
Example to log to disk only INFO and higher (ignore DEBUG)
```
*log.py
file_handler.setLevel(logging.INFO) # DEBUG used by default for system logs to disk example here shows INFO
```

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
import pickle # pip install pickle
from modules.log import *
trap_list_bbs = ("bbslist", "bbspost", "bbsread", "bbsdelete", "bbshelp")
trap_list_bbs = ("bbslist", "bbspost", "bbsread", "bbsdelete", "bbshelp", "bbsinfo")
# global message list, later we will use a pickle on disk
bbs_messages = []
@@ -16,7 +16,7 @@ def load_bbsdb():
try:
with open('bbsdb.pkl', 'rb') as f:
bbs_messages = pickle.load(f)
except:
except Exception as e:
bbs_messages = [[1, "Welcome to meshBBS", "Welcome to the BBS, please post a message!",0]]
logger.debug("System: Creating new bbsdb.pkl")
with open('bbsdb.pkl', 'wb') as f:
@@ -130,6 +130,11 @@ def bbs_post_dm(toNode, message, fromNode):
save_bbsdm()
return "BBS DM Posted for node " + str(toNode)
def get_bbs_stats():
global bbs_messages, bbs_dm
# Return some stats on the bbs pending messages and total posted messages
return f"📡BBSdb has {len(bbs_messages)} messages. Direct ✉️ Messages waiting: {(len(bbs_dm) - 1)}"
def bbs_check_dm(toNode):
global bbs_dm
# Check for any messages for toNode

View File

@@ -4,6 +4,7 @@
from random import choices, shuffle
from modules.log import *
import time
import pickle
jack_starting_cash = 100 # Replace 100 with your desired starting cash value
jackTracker= [{'nodeID': 0, 'cmd': 'new', 'time': time.time(), 'cash': jack_starting_cash,\
@@ -113,15 +114,6 @@ class jackChips:
self.total -= self.bet
self.winnings -= 1
def take_bet(bet_amount, player_money):
try:
if bet_amount >= player_money or bet_amount <= 0:
return f"Enter a bet amount between 1 and {player_money}"
return bet_amount
except TypeError:
return "Invalid bet amount"
def success_rate(card, obj_h):
""" Calculate Success rate of 'HIT' new cards """
msg = ""
@@ -132,13 +124,11 @@ def success_rate(card, obj_h):
if rate < 100:
msg += f"If Hit, chance {int(rate)}% failure, {100-int(rate)}% success."
elif rate > 100:
else:
l_rate = int(rate - (rate - 99)) # Round to 99
if card[0][1] == "A":
l_rate -= 99
msg += f"If Hit, chance {100-l_rate}% failure, and {l_rate}% success"
else:
msg += f"If Hit, a low chance of success."
return msg
def hits(obj_de):
@@ -216,9 +206,33 @@ def setLastCmdJack(nodeID, cmd):
return True
return False
def saveHSJack(nodeID, highScore):
# Save the game state to pickle
highScore = {'nodeID': nodeID, 'highScore': highScore}
try:
with open('blackjack_hs.pkl', 'wb') as file:
pickle.dump(highScore, file)
except FileNotFoundError:
logger.debug("System: BlackJack: Creating new blackjack_hs.pkl file")
with open('blackjack_hs.pkl', 'wb') as file:
pickle.dump(highScore, file)
def loadHSJack():
try:
with open('blackjack_hs.pkl', 'rb') as file:
highScore = pickle.load(file)
return highScore
except FileNotFoundError:
logger.debug("System: BlackJack: Creating new blackjack_hs.pkl file")
highScore = {'nodeID': 0, 'highScore': 0}
with open('blackjack_hs.pkl', 'wb') as file:
pickle.dump(highScore, file)
return 0
def playBlackJack(nodeID, message):
# Initalize the Game
msg, last_cmd = '', None
blackJack = False
p_win, d_win, draw = 0, 0, 0
p_chips = jackChips()
p_hand = jackHand()
@@ -243,8 +257,8 @@ def playBlackJack(nodeID, message):
d_win = jackTracker[i]['gameStats']['d_win']
draw = jackTracker[i]['gameStats']['draw']
bet_money = jackTracker[i]['bet']
p_chips.bet = bet_money
if last_cmd == "playing":
p_chips.bet = bet_money
p_cards = jackTracker[i]['p_cards']
d_cards = jackTracker[i]['d_cards']
p_hand = jackTracker[i]['p_hand']
@@ -256,42 +270,44 @@ def playBlackJack(nodeID, message):
logger.debug(f"System: BlackJack: New Player {nodeID}")
jackTracker.append({'nodeID': nodeID, 'cmd': 'new', 'time': time.time(), 'cash': jack_starting_cash,\
'bet': 0, 'gameStats': {'p_win': p_win, 'd_win': d_win, 'draw': draw}, 'p_cards':p_cards, 'd_cards':d_cards, 'p_hand':p_hand.cards, 'd_hand':d_hand.cards, 'next_card':next_card})
return f"Welcome to BlackJack!♠️♥️♣️♦️ you have {p_chips.total} chips, Whats your bet?"
return f"Welcome to ♠️♥️BlackJack♣ you have {p_chips.total} chips. Whats your bet?"
if getLastCmdJack(nodeID) == "new":
# Place Bet
try:
# handle B letter
if message == "b":
if message.lower() == "b":
if bet_money == 0:
bet_money = 5
else:
bet_money = bet_money
# handle # message
if bet_money != 0:
bet_money = int(bet_money)
elif message.lower() == "r":
#resend the hand
msg += show_some(p_cards, d_cards, p_hand)
return msg
else:
bet_money = int(message)
try:
bet_money = int(message)
except ValueError:
return "Invalid Bet, please enter a valid number."
if bet_money <= p_chips.total or bet_money <= 1:
p_chips.bet = take_bet(bet_money, p_chips.total)
if bet_money <= p_chips.total and bet_money >= 1:
p_chips.bet = bet_money
else:
return f"Invalid Bet, the maximum bet you can place is {p_chips.total}"
return f"Invalid Bet, the maximum bet you can place is {p_chips.total} and the minimum bet is 1."
except ValueError:
return f"Invalid Bet, the maximum bet you can place is {p_chips.total}"
return f"Invalid Bet, the maximum bet, {p_chips.total}"
# Show the cards
msg += show_some(p_cards, d_cards, p_hand)
# check for blackjack 21 and only two cards
if p_hand.value == 21 and len(p_hand.cards) == 2:
msg += "Player 🎰 BLAAAACKJACKKKK 💰"
p_chips.total += round(p_chips.bet * 1.5)
setLastCmdJack(nodeID, "dealerTurn")
blackJack = True
# Save the game state
for i in range(len(jackTracker)):
if jackTracker[i]['nodeID'] == nodeID:
jackTracker[i]['cash'] = p_chips.total
jackTracker[i]['cash'] = int(p_chips.total)
break
else:
# Display the statistics
@@ -299,10 +315,9 @@ def playBlackJack(nodeID, message):
msg += stats
setLastCmdJack(nodeID, "betPlaced")
if getLastCmdJack(nodeID) == "betPlaced":
setLastCmdJack(nodeID, "playing")
msg += "(H)it,(S)tand,(F)orfit,(D)ouble"
msg += "(H)it,(S)tand,(F)orfit,(D)ouble,(R)esend,(L)eave table"
# save the game state
for i in range(len(jackTracker)):
@@ -344,27 +359,29 @@ def playBlackJack(nodeID, message):
setLastCmdJack(nodeID, "dealerTurn")
else:
return "You can't Double Down, dont have enough chips"
elif choice == "resend" or choice == "r":
msg += show_some(p_hand.cards, d_cards, p_hand)
else:
return "Invalid Choice"
return "(H)it,(S)tand,(F)orfit,(D)ouble,(R)esend,(L)eave table"
# Check if player bust
if player_bust(p_hand, p_chips):
d_win += 1
msg += "Player:BUST💥"
msg += "💥PlayerBUST💥"
setLastCmdJack(nodeID, "dealerTurn")
if getLastCmdJack(nodeID) == "playing":
msg += stats
msg += "[H,S,F,D,L]"
msg += "[H,S,F,D]"
# Save the game state
for i in range(len(jackTracker)):
if jackTracker[i]['nodeID'] == nodeID:
jackTracker[i]['cash'] = p_chips.total
jackTracker[i]['bet'] = p_chips.bet
jackTracker[i]['gameStats']['p_win'] = p_win
jackTracker[i]['gameStats']['d_win'] = d_win
jackTracker[i]['gameStats']['draw'] = draw
jackTracker[i]['cash'] = int(p_chips.total)
jackTracker[i]['bet'] = int(p_chips.bet)
jackTracker[i]['gameStats']['p_win'] = int(p_win)
jackTracker[i]['gameStats']['d_win'] = int(d_win)
jackTracker[i]['gameStats']['draw'] = int(draw)
jackTracker[i]['p_cards'] = p_cards
jackTracker[i]['d_cards'] = d_cards
jackTracker[i]['p_hand'] = p_hand
@@ -378,20 +395,22 @@ def playBlackJack(nodeID, message):
return msg
if getLastCmdJack(nodeID) == "dealerTurn":
# Dealers Turn
if not blackJack:
# recall the game state
for i in range(len(jackTracker)):
if jackTracker[i]['nodeID'] == nodeID:
p_chips.total = jackTracker[i]['cash']
p_chips.bet = jackTracker[i]['bet']
p_win = jackTracker[i]['gameStats']['p_win']
d_win = jackTracker[i]['gameStats']['d_win']
draw = jackTracker[i]['gameStats']['draw']
p_cards = jackTracker[i]['p_cards']
d_cards = jackTracker[i]['d_cards']
p_hand = jackTracker[i]['p_hand']
d_hand = jackTracker[i]['d_hand']
next_card = jackTracker[i]['next_card']
break
for i in range(len(jackTracker)):
if jackTracker[i]['nodeID'] == nodeID:
p_chips.total = jackTracker[i]['cash']
p_chips.bet = jackTracker[i]['bet']
p_win = jackTracker[i]['gameStats']['p_win']
d_win = jackTracker[i]['gameStats']['d_win']
draw = jackTracker[i]['gameStats']['draw']
p_cards = jackTracker[i]['p_cards']
d_cards = jackTracker[i]['d_cards']
p_hand = jackTracker[i]['p_hand']
d_hand = jackTracker[i]['d_hand']
next_card = jackTracker[i]['next_card']
break
if p_hand.value <= 21:
# Dealer's Turn
@@ -400,7 +419,7 @@ def playBlackJack(nodeID, message):
d_hand.add_cards(d_card)
if dealer_bust(d_hand, p_hand, p_chips):
p_win += 1
msg += "Dealer:BUST💥"
msg += "💰DealerBUST💥"
break
# Show all cards
msg += show_all(p_hand.cards, d_hand.cards, p_hand, d_hand)
@@ -408,15 +427,15 @@ def playBlackJack(nodeID, message):
# Check who wins
if push(p_hand, d_hand):
draw += 1
msg += f"👌PUSH"
msg += "👌PUSH"
elif player_wins(p_hand, d_hand, p_chips):
p_win += 1
msg += f"🎉PLAYER WINS🎰"
msg += "🎉PLAYER WINS🎰"
elif dealer_wins(p_hand, d_hand, p_chips):
d_win += 1
msg += f"👎DEALER WINS"
msg += "👎DEALER WINS"
else:
msg += f"👎DEALER WINS"
msg += "👎DEALER WINS"
# Display the Game Stats
msg += gameStats(str(p_win), str(d_win), str(draw))
@@ -424,14 +443,20 @@ def playBlackJack(nodeID, message):
# Display the chips left
if p_chips.total < 1:
if p_chips.total > 0:
msg += f"🪙Keep the change you filthy animal!"
msg += "🪙Keep the change you filthy animal!"
else:
msg += "💸NO MORE MONEY! Game Over!"
msg += "💸NO MORE CHIPS!🏧💳"
p_chips.total = jack_starting_cash
else:
msg += f"💰You have {p_chips.total} chips left"
# check high score
highScore = loadHSJack()
if highScore != 0 and p_chips.total > highScore['highScore']:
msg += f"💰HighScore💰{p_chips.total} "
saveHSJack(nodeID, p_chips.total)
else:
msg += f"💰You have {p_chips.total} chips "
msg += "(B)et or (L)eave table."
msg += " Bet or Leave?"
# Reset the game
setLastCmdJack(nodeID, "new")

View File

@@ -204,7 +204,7 @@ def buy_func(nodeID, price_list, choice=0, value='0'):
if drug_choice in range(1, len(my_drugs) + 1):
drug_choice = drug_choice - 1
msg = my_drugs[drug_choice].name + ": you have🎒 " + str(amount[drug_choice]) + " "
msg += " The going price is: $" + str(price_list[drug_choice]) + " "
msg += " The going price is: $" + "{:,}".format(price_list[drug_choice]) + " "
buy_amount = value
if buy_amount == 'm':
@@ -218,7 +218,7 @@ def buy_func(nodeID, price_list, choice=0, value='0'):
msg = f"Didnt see a qty. ex: b,1,10 buys 10 of {my_drugs[1].name}, can also use m for max"
return msg
elif buy_amount not in range(1, 101):
msg = f"Enter qty or m for max"
msg = "Enter qty or m for max"
return msg
elif buy_amount > 100 - inventory:
msg = "You don\'t have enough space for all that.🎒"
@@ -228,7 +228,7 @@ def buy_func(nodeID, price_list, choice=0, value='0'):
cash -= buy_amount * price_list[drug_choice]
inventory += buy_amount
msg += "You bought " + str(buy_amount) + " " + my_drugs[drug_choice].name + '. Remaining cash: $' + str(cash)
msg += f"\nBuy Sell Fly?"
msg += f"\nBuy💸, Sell💰, Fly🛫?"
else:
msg = "You don't have enough cash!😭"
return msg
@@ -273,10 +273,10 @@ def sell_func(nodeID, price_list, choice=0, value='0'):
else:
sell_amount = int(sell_amount)
if sell_amount not in range(1, 101):
msg = f"You can only sell between 1 and 100"
msg = "You can only sell between 1 and 100"
return msg
except ValueError:
msg = f"Enter qty or m for max"
msg = "Enter qty or m for max"
return msg
# check if the user has any of the drug they are trying to sell
@@ -294,7 +294,7 @@ def sell_func(nodeID, price_list, choice=0, value='0'):
cash += sell_amount * price_list[drug_choice]
inventory -= sell_amount
msg += " You sold " + str(sell_amount) + " " + my_drugs[drug_choice].name + ' for $' +\
str(sell_amount * price_list[drug_choice]) + '. Total cash: $' + str(cash)
str(sell_amount * price_list[drug_choice]) + '. Total cash: $' + "{:,}".format(cash)
else:
msg = "You don't have that much"
return msg
@@ -329,7 +329,7 @@ def get_location_table(nodeID, choice=0):
loc_table_string = ''
for i in range(len(loc)):
loc_table_string += str(i+1) + '. ' + loc[i] + ' '
loc_table_string += f' Where do you want to 🛫?#'
loc_table_string += ' Where do you want to 🛫?#'
return loc_table_string
@@ -421,11 +421,11 @@ def render_game_screen(userID, day_play, total_day, loc_choice, event_number, pr
if dwCashDb[i].get('userID') == userID:
cash = dwCashDb[i].get('cash')
msg += "Location: " + loc[int(loc_choice) - 1] + ", Day:" + str(day_play) + '/' + str(total_day) + " 🎒: " + str(inventory) + "/100" + ", $" + str(cash) + f"\n"
msg += "🗺️" + loc[int(loc_choice) - 1] + " 📆" + str(day_play) + '/' + str(total_day) + " 🎒" + str(inventory) + "/100" + " 💵" + "{:,}".format(cash) + f"\n"
for i, drug in enumerate(my_drugs, 1):
qty = amount[i-1]
msg += f'#{str(i)}.{drug.name}/${price_list[i-1]}({qty}) '
msg += f'#{str(i)}.{drug.name}${"{:,}".format(price_list[i-1])}({qty}) '
return msg
@@ -516,7 +516,7 @@ def playDopeWars(nodeID, cmd):
dwPlayerTracker[i]['cmd'] = 'location'
if last_cmd == 'ask_bsf':
msg = 'example Buy: b,Drug,Qty or Sell s,1,10. Fly: f. Price list: p or end'
msg = f'example buy:\nb,drug#,qty# or Sell: s,1,10 qty can be (m)ax\n f,p or end'
menu_choice = cmd.lower()
if ',' in menu_choice or '.' in menu_choice:
#split the choice into a letter and a number for the buy/sell functions
@@ -539,7 +539,7 @@ def playDopeWars(nodeID, cmd):
menu_choice[2] = int(menu_choice[2])
except ValueError:
msg = 'a value was bad, example dopeware Buy or Sell b,1,10 or s,1,m'
msg = f'a value was bad, example dopeware Buy or Sell\n b,1,10 or s,1,m'
return msg
if menu_choice[0] == 'b':
@@ -589,7 +589,7 @@ def playDopeWars(nodeID, cmd):
msg = endGameDw(nodeID)
return msg
else:
msg = 'example Buy: b,Drug,Qty or Sell s,1,10. Fly: f. Price list: p or end'
msg = f'example buy:\nb,drug#,qty# or Sell: s,1,10 qty can be (m)ax\n f,p or end'
return msg
# Buy
@@ -639,7 +639,7 @@ def playDopeWars(nodeID, cmd):
# Display Main Game Screen and ask for buy, sell, or fly
if last_cmd == 'display_main':
msg = dopeWarGameDay(nodeID, game_day, total_days)
msg += f"\nBuy, Sell, Fly? Price list?"
msg += f"\nBuy💸, Sell💰, (F)ly🛫? (P)riceList?"
# set the player's last command
for i in range(0, len(dwPlayerTracker)):
if dwPlayerTracker[i].get('userID') == nodeID:

409
modules/golfsim.py Normal file
View File

@@ -0,0 +1,409 @@
# https://github.com/danfriedman30/pythongame
# Adapted for Meshtastic mesh-bot by K7MHI Kelly Keeton 2024
import random
import time
import pickle
from modules.log import *
# Clubs setup
driver_distances = list(range(230, 280, 5))
low_distances = list(range(185, 215, 5))
mid_distances = list(range(130, 185, 5))
high_distances = list(range(90, 135, 5))
gap_wedge_distances = list(range(50, 85, 5))
lob_wedge_distances = list(range(10, 50, 5))
putt_outcomes = [1, 2, 3]
# Hole/Course Setup
full_hole_range = list(range(130, 520, 5))
par3_range = list(range(130, 255, 5))
par4_range = list(range(255, 445, 5))
par5_range = list(range(445, 520, 5))
par3_4_range = par3_range + par4_range
par3_5_range = par3_range + par5_range
par4_5_range = par4_range + par5_range
# Player setup
playingHole = False
golfTracker = [{'nodeID': 0, 'last_played': time.time(), 'cmd': '', 'hole': 0, 'distance_remaining': 0, 'hole_shots': 0, 'hole_strokes': 0, 'hole_to_par': 0, 'total_strokes': 0, 'total_to_par': 0, 'par': 0, 'hazard': ''}]
# Club functions
def hit_driver():
club_distance = random.choice(driver_distances)
return club_distance
def hit_low_iron():
club_distance = random.choice(low_distances)
return club_distance
def hit_mid_iron():
club_distance = random.choice(mid_distances)
return club_distance
def hit_high_iron():
club_distance = random.choice(high_distances)
return club_distance
def hit_gap_wedge():
club_distance = random.choice(gap_wedge_distances)
return club_distance
def hit_lob_wedge():
club_distance = random.choice(lob_wedge_distances)
return club_distance
def finish_hole():
finish = random.choice(putt_outcomes)
return finish
def endGameGolf(nodeID):
# pop player from tracker
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
golfTracker.pop(i)
logger.debug("System: GolfSim: Player " + str(nodeID) + " has ended their round.")
def getScorecardGolf(scorecard):
# Scorecard messages, convert score to message comment
msg = ""
if scorecard == 8:
# Quadruple bogey
msg += " +Quad Bogey☃ "
elif scorecard == 7:
# Triple bogey
msg += " +Triple Bogey "
elif scorecard == 6:
# Double bogey
msg += " +Double Bogey "
elif scorecard == 5:
# Bogey
msg += " +Bogey "
elif scorecard > 0:
# Over par
msg += f" +Par {str(scorecard)} "
elif scorecard == 0:
# Even par
msg += " Even Par💪 "
elif scorecard == -1:
# Birdie
msg += " -Birdie🐦 "
elif scorecard == -2:
# Eagle
msg += " -Eagle🦅 "
elif scorecard == -3:
# Albatross
msg += " -Albatross🦅🦅 "
else:
# Under par
msg += f" -Par {str(abs(scorecard))} "
return msg
def getHighScoreGolf(nodeID, strokes, par):
# check if player is in high score list
try:
with open('golfsim_hs.pkl', 'rb') as f:
golfHighScore = pickle.load(f)
except:
logger.debug("System: GolfSim: High Score file not found.")
golfHighScore = [{'nodeID': nodeID, 'strokes': strokes, 'par': par}]
with open('golfsim_hs.pkl', 'wb') as f:
pickle.dump(golfHighScore, f)
if strokes < golfHighScore[0]['strokes']:
# player got new low score which is high score
golfHighScore[0]['nodeID'] = nodeID
golfHighScore[0]['strokes'] = strokes
golfHighScore[0]['par'] = par
with open('golfsim_hs.pkl', 'wb') as f:
pickle.dump(golfHighScore, f)
return golfHighScore
return 0
# Main game loop
def playGolf(nodeID, message, finishedHole=False):
msg = ''
global golfTracker
# Course setup
par3_count = 0
par4_count = 0
par5_count = 0
# Scorecard setup
total_strokes = 0
total_to_par = 0
par = 0
# get player's last command from tracker if not new player
last_cmd = ""
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
last_cmd = golfTracker[i]['cmd']
hole = golfTracker[i]['hole']
distance_remaining = golfTracker[i]['distance_remaining']
hole_shots = golfTracker[i]['hole_shots']
par = golfTracker[i]['par']
total_strokes = golfTracker[i]['total_strokes']
total_to_par = golfTracker[i]['total_to_par']
if last_cmd == "" or last_cmd == "new":
# Start a new hole
if hole <= 9:
# Set up hole count restrictions on par
if par3_count < 2 and par4_count < 5 and par5_count < 2:
hole_length = random.choice(full_hole_range)
if par3_count >= 2 and par4_count < 5 and par5_count < 2:
hole_length = random.choice(par4_5_range)
if par3_count >= 2 and par4_count < 5 and par5_count >= 2:
hole_length = random.choice(par4_range)
if par3_count < 2 and par4_count < 5 and par5_count >= 2:
hole_length = random.choice(par3_4_range)
if par3_count < 2 and par4_count >= 5 and par5_count >= 2:
hole_length = random.choice(par3_range)
if par3_count >= 2 and par4_count >= 5 and par5_count < 2:
hole_length = random.choice(par5_range)
if par3_count < 2 and par4_count >= 5 and par5_count < 2:
hole_length = random.choice(par3_5_range)
# Set up par for the hole
if hole_length <= 250:
par = 3
par3_count += 1
elif hole_length > 250 and hole_length <= 440:
par = 4
par4_count += 1
elif hole_length > 440:
par = 5
par5_count += 1
# roll for chance of hazard
hazard_chance = random.randint(1, 100)
weather_chance = random.randint(1, 100)
# have low chances of hazards and weather
hasHazard = False
hazard = ""
if hazard_chance < 25:
# Further reduce chance of hazards with weather
if weather_chance < 15:
# randomly calculate a hazard for the hole sand, 🌊, 🌲, 🏘️, etc
hazard = random.choice(["🏖️", "🌊", "🌲", "🏘️"])
hasHazard = True
# Set initial parameters before starting a hole
distance_remaining = hole_length
hole_shots = 0
# save player's current game state
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
golfTracker[i]['distance_remaining'] = distance_remaining
golfTracker[i]['cmd'] = 'stroking'
golfTracker[i]['par'] = par
golfTracker[i]['total_strokes'] = total_strokes
golfTracker[i]['total_to_par'] = total_to_par
golfTracker[i]['hazard'] = hazard
golfTracker[i]['hole'] = hole
golfTracker[i]['last_played'] = time.time()
golfTracker[i]['hole_shots'] = hole_shots
# Show player the hole information
msg += "⛳️#" + str(hole) + " is a " + str(hole_length) + "-yard Par " + str(par) + "."
if hasHazard:
msg += "⚠️" + hazard + "."
else:
# add weather conditions with random choice from list, this is fluff
msg += random.choice(["☀️", "💨", "☀️", "☀️", "⛅️", "☁️", "☀️"])
if not finishedHole:
msg += f"\nChoose your club."
return msg
if last_cmd == 'stroking':
# Get player's current game state
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
distance_remaining = golfTracker[i]['distance_remaining']
hole = golfTracker[i]['hole']
hole_shots = golfTracker[i]['hole_shots']
par = golfTracker[i]['par']
total_strokes = golfTracker[i]['total_strokes']
total_to_par = golfTracker[i]['total_to_par']
hazard = golfTracker[i]['hazard']
# Start loop to be able to choose clubs while at least 20 yards away
if distance_remaining >= 20:
msg = ""
club = message.lower()
shot_distance = 0
pin_distance = distance_remaining
if club == "driver" or club.startswith("d"):
shot_distance = hit_driver()
msg += "🏌Hit D " + str(shot_distance) + "yd. "
distance_remaining = abs(distance_remaining - shot_distance)
hole_shots += 1
elif "low" in club or club.startswith("l"):
shot_distance = hit_low_iron()
msg += "🏌Hit L Iron " + str(shot_distance) + "yd. "
distance_remaining = abs(distance_remaining - shot_distance)
hole_shots += 1
elif "mid" in club or club.startswith("m"):
shot_distance = hit_mid_iron()
msg += "🏌Hit M Iron " + str(shot_distance) + "yd. "
distance_remaining = abs(distance_remaining - shot_distance)
hole_shots += 1
elif "high" in club or club.startswith("h"):
shot_distance = hit_high_iron()
msg += "🏌Hit H Iron " + str(shot_distance) + "yd. "
distance_remaining = abs(distance_remaining - shot_distance)
hole_shots += 1
elif "gap" in club or club.startswith("g"):
shot_distance = hit_gap_wedge()
msg += "🏌Hit G Wedge " + str(shot_distance) + "yd ."
distance_remaining = abs(distance_remaining - shot_distance)
hole_shots += 1
elif "wedge" in club or club.startswith("w"):
shot_distance = hit_lob_wedge()
msg += "🏌Hit L Wedge " + str(shot_distance) + "yd. "
distance_remaining = abs(distance_remaining - shot_distance)
hole_shots += 1
elif club == "caddy" or club.startswith("c"):
# Show player the club distances
msg += f"Caddy Guess:\nD:{hit_driver()} L:{hit_low_iron()} M:{hit_mid_iron()} H:{hit_high_iron()} G:{hit_gap_wedge()} W:{hit_lob_wedge()}"
else:
msg += "Didnt get your club 🥪♣️🪩 choice"
return msg
if distance_remaining - pin_distance > pin_distance or shot_distance > pin_distance:
# Check for over-shooting the hole
if distance_remaining > 20:
# did it go off the "green"?
msg += "Overshot the green!🚀"
if distance_remaining == 0:
msg += "🎯Perfect shot! "
last_cmd = 'putt'
elif distance_remaining < 20:
# Roll Dice
hole_in_one_chance = random.randint(1, 100)
wind_factor = random.randint(1, 10)
skill_factor = random.randint(1, 10)
critter_factor = random.randint(1, 50)
# Check for hole in one
if hole_in_one_chance <= 5 and wind_factor > 7 and skill_factor > 8:
distance_remaining = 0
# Check for critters
if skill_factor > 8 and critter_factor < 40 and wind_factor > 2 and hole_in_one_chance > 5:
msg += random.choice(["A 🐿️ steals your ball!😡 ","You Hit a 🦅 soring past ", "🐊 need we say more? ", "hit a 🪟 of a 🏡 "])
distance_remaining = -1
# Handle hazard
if hazard == "🌊" and skill_factor < 7:
msg += "In the water!🌊"
distance_remaining = -1
if hazard == "🏖️" and skill_factor < 5:
msg += "In the sand!🏖️"
distance_remaining = random.randint(5, 10)
if hazard == "🌲" and skill_factor < 3:
msg += "In the trees!🌲"
distance_remaining += random.randint(5, 20)
if hazard == "🏘️" and skill_factor < 2:
msg += "In the parking lot!🚗"
distance_remaining += random.randint(10, 30)
# Check we didnt go off the green or into a hazard
if distance_remaining < 20:
last_cmd = 'putt'
else:
last_cmd = 'stroking'
else:
msg += "\nYou have " + str(distance_remaining) + "yd. ⛳️"
msg += "\nClub?[D, L, M, H, G, W]🏌️"
# save player's current game state, keep stroking
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
golfTracker[i]['distance_remaining'] = distance_remaining
golfTracker[i]['hole_shots'] = hole_shots
golfTracker[i]['total_strokes'] = total_strokes
golfTracker[i]['cmd'] = 'stroking'
return msg
if last_cmd == 'putt':
# Finish the hole by putting
critter = False
if distance_remaining < 20:
if distance_remaining == 0:
putts = 0
elif distance_remaining == -1:
putts = 0
critter = True
else:
putts = finish_hole()
# Calculate hole and round scores
hole_strokes = hole_shots + putts
hole_to_par = hole_strokes - par
total_strokes += hole_strokes
total_to_par += hole_to_par
if not critter:
# Show player hole/round scoring info
if putts == 0 and hole_strokes == 1:
msg += "🎯Hole in one!⛳️"
elif putts == 0:
msg += "You're in the hole at " + str(hole_strokes) + " strokes!"
else:
msg += "You're on the green! After " + str(putts) + " putt(s), you're in for " + str(hole_strokes) + " strokes."
msg += getScorecardGolf(hole_to_par)
if hole not in [1, 10]:
# Show player total scoring info for the round, except hole 1 and 10
msg += "\nYou've hit a total of " + str(total_strokes) + " strokes today, for"
msg += getScorecardGolf(total_to_par)
# Move to next hole
hole += 1
else:
msg += f"Got a new ball at Pro-Shop, marshal put you @" # flow into same hole haha
# Scorecard reset
hole_to_par = 0
total_to_par = 0
hole_strokes = 0
hole_shots = 0
# Save player's current game state
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
golfTracker[i]['hole_strokes'] = hole_strokes
golfTracker[i]['hole_to_par'] = hole_to_par
golfTracker[i]['total_strokes'] = total_strokes
golfTracker[i]['total_to_par'] = total_to_par
golfTracker[i]['hole'] = hole
golfTracker[i]['cmd'] = 'new'
golfTracker[i]['last_played'] = time.time()
if hole >= 9:
# Final score messages & exit prompt
msg += f"🎉Finished 9-hole round⛳"
#HighScore Display
highscore = getHighScoreGolf(nodeID, total_strokes, total_to_par)
if highscore != 0:
msg += "\n🏆New Club Record🏆"
# pop player from tracker
for i in range(len(golfTracker)):
if golfTracker[i]['nodeID'] == nodeID:
golfTracker.pop(i)
logger.debug("System: GolfSim: Player " + str(nodeID) + " has finished their round.")
else:
# Show player the next hole
msg += playGolf(nodeID, 'new', True)
msg += "\n🏌️[D, L, M, H, G, W, End]🏌️"
return msg

View File

@@ -38,15 +38,13 @@ def get_sales_amount(potential, unit, price):
return math.floor(potential * (unit / (price ** 1.5)))
def getHighScoreLemon():
global high_score
high_score = {"userID": 0, "cash": 0, "success": 0}
# Load high score table
try:
with open('lemonade_hs.pkl', 'rb') as file:
high_score = pickle.load(file)
except FileNotFoundError:
logger.debug("System: Lemonade: No high score table found")
# high score pickle file is a touple of the nodeID and the high score
high_score = ({"userID": 4258675309, "cash": 2, "success": 0})
# write a new high score file if one is not found
with open('lemonade_hs.pkl', 'wb') as file:
pickle.dump(high_score, file)
@@ -121,7 +119,7 @@ def start_lemonade(nodeID, message, celsius=False):
endGame(nodeID)
return "Goodbye!👋"
title="Lemonade Stand🍋"
title="LemonStand🍋"
# Define the temperature unit symbols
fahrenheit_unit = "ºF"
celsius_unit = "ºC"

View File

@@ -204,6 +204,7 @@ def abbreviate_weather(row):
"precipitation": "precip",
"showers": "shwrs",
"thunderstorms": "t-storms",
"thunderstorm": "t-storm",
"quarters": "qtrs",
"quarter": "qtr"
}

View File

@@ -59,14 +59,14 @@ stdout_handler.setFormatter(CustomFormatter(logFormat))
logger.addHandler(stdout_handler)
if syslog_to_file:
# Create file handler for logging to a file
file_handler = logging.FileHandler('system{}.log'.format(today.strftime('%Y_%m_%d')))
file_handler = logging.FileHandler('logs/system{}.log'.format(today.strftime('%Y_%m_%d')))
file_handler.setLevel(logging.DEBUG) # DEBUG used by default for system logs to disk
file_handler.setFormatter(logging.Formatter(logFormat))
logger.addHandler(file_handler)
if log_messages_to_file:
# Create file handler for logging to a file
file_handler = logging.FileHandler('messages{}.log'.format(today.strftime('%Y_%m_%d')))
file_handler = logging.FileHandler('logs/messages{}.log'.format(today.strftime('%Y_%m_%d')))
file_handler.setLevel(logging.INFO) # INFO used for messages to disk
file_handler.setFormatter(logging.Formatter(msgLogFormat))
msgLogger.addHandler(file_handler)

341
modules/mmind.py Normal file
View File

@@ -0,0 +1,341 @@
# https://github.com/pwdkramer/pythonMastermind/blob/main/main.py
# Adapted for Meshtastic mesh-bot by K7MHI Kelly Keeton 2024
import random
import time
import pickle
from modules.log import *
mindTracker = [{'nodeID': 0, 'last_played': time.time(), 'cmd': '', 'secret_code': '', 'diff': 'n', 'turns': 1}]
def chooseDifficultyMMind(message):
usrInput = message.lower()
msg = ''
valid_colorsMMind = "RYGB"
if not usrInput.startswith("n") and not usrInput.startswith("h") and not usrInput.startswith("x"):
# default to normal difficulty
usrInput = "n"
if usrInput == "n":
msg += f"The colors to choose from are:\nR🔴, Y🟡, G🟢, B🔵"
elif usrInput == "h":
valid_colorsMMind += "OP"
msg += f"The colors to choose from are\nR🔴, Y🟡, G🟢, B🔵, O🟠, P🟣"
elif usrInput == "x":
valid_colorsMMind += "OPWK"
msg += f"The colors to choose from are\nR🔴, Y🟡, G🟢, B🔵, O🟠, P🟣, W⚪, K⚫"
return msg
#possible colors on nomral: Red, Yellow, Green, Blue
#added colors on hard: Orange, Purple
def makeCodeMMind(diff):
secret_code = ""
for i in range(4):
if diff == "n":
roll = random.randrange(1, 5)
elif diff == "h":
roll = random.randrange(1,7)
elif diff == "x":
roll = random.randrange(1,9)
else:
print("Difficulty error in makeCode()")
if roll == 1:
secret_code += "R"
elif roll == 2:
secret_code += "Y"
elif roll == 3:
secret_code += "G"
elif roll == 4:
secret_code += "B"
elif roll == 5:
secret_code += "O"
elif roll == 6:
secret_code += "P"
elif roll == 7:
secret_code += "W"
elif roll == 8:
secret_code += "K"
else:
print("Error with range of roll in makeCode()")
return secret_code
#get guess from user
def getGuessMMind(diff, guess):
msg = ''
if diff == "n":
valid_colorsMMind = "RYGB"
elif diff == "h":
valid_colorsMMind = "RYGBOP"
elif diff == "x":
valid_colorsMMind = "RYGBOPWK"
user_guess = guess.upper()
valid_guess = True
if len(user_guess) != 4:
valid_guess = False
for i in range(len(user_guess)):
if user_guess[i] not in valid_colorsMMind:
valid_guess = False
if valid_guess == False:
user_guess = "XXXX"
return user_guess
def getHighScoreMMind(nodeID, turns, diff):
# check if player is in high score list and pick the lowest score
try:
with open('mmind_hs.pkl', 'rb') as f:
mindHighScore = pickle.load(f)
except:
logger.debug("System: MasterMind: High Score file not found.")
mindHighScore = [{'nodeID': nodeID, 'turns': turns, 'diff': diff}]
with open('mmind_hs.pkl', 'wb') as f:
pickle.dump(mindHighScore, f)
if nodeID == 0:
# just return the high score
return mindHighScore
# calculate lowest score
lowest_score = mindHighScore[0]['turns']
if mindHighScore[0]['diff'] == "n" and diff == "n":
if lowest_score > turns:
# update the high score for normal if new score is lower
mindHighScore[0]['nodeID'] = nodeID
mindHighScore[0]['turns'] = turns
mindHighScore[0]['diff'] = diff
# write new high score to file
with open('mmind_hs.pkl', 'wb') as f:
pickle.dump(mindHighScore, f)
return mindHighScore
elif mindHighScore[0]['diff'] == "n" and diff == "h":
# update the high score for hard if normal is the only high score
mindHighScore[0]['nodeID'] = nodeID
mindHighScore[0]['turns'] = turns
mindHighScore[0]['diff'] = diff
# write new high score to file
with open('mmind_hs.pkl', 'wb') as f:
pickle.dump(mindHighScore, f)
return mindHighScore
elif mindHighScore[0]['diff'] == "h" and diff == "h":
if lowest_score > turns:
# update the high score for hard if new score is lower
mindHighScore[0]['nodeID'] = nodeID
mindHighScore[0]['turns'] = turns
mindHighScore[0]['diff'] = diff
# write new high score to file
with open('mmind_hs.pkl', 'wb') as f:
pickle.dump(mindHighScore, f)
return mindHighScore
elif mindHighScore[0]['diff'] == "n" or mindHighScore[0]['diff'] == "h" and diff == "x":
# update the high score for expert if normal or high is the only high score
mindHighScore[0]['nodeID'] = nodeID
mindHighScore[0]['turns'] = turns
mindHighScore[0]['diff'] = diff
# write new high score to file
with open('mmind_hs.pkl', 'wb') as f:
pickle.dump(mindHighScore, f)
return mindHighScore
elif mindHighScore[0]['diff'] == "x" and diff == "x":
if lowest_score > turns:
# update the high score for expert if new score is lower
mindHighScore[0]['nodeID'] = nodeID
mindHighScore[0]['turns'] = turns
mindHighScore[0]['diff'] = diff
# write new high score to file
with open('mmind_hs.pkl', 'wb') as f:
pickle.dump(mindHighScore, f)
return mindHighScore
return 0
def getEmojiMMind(secret_code):
# for each letter in the secret code, convert to emoji for display
secret_code = secret_code.upper()
secret_code_emoji = ""
for i in range(len(secret_code)):
if secret_code[i] == "R":
secret_code_emoji += "🔴"
elif secret_code[i] == "Y":
secret_code_emoji += "🟡"
elif secret_code[i] == "G":
secret_code_emoji += "🟢"
elif secret_code[i] == "B":
secret_code_emoji += "🔵"
elif secret_code[i] == "O":
secret_code_emoji += "🟠"
elif secret_code[i] == "P":
secret_code_emoji += "🟣"
elif secret_code[i] == "W":
secret_code_emoji += ""
elif secret_code[i] == "K":
secret_code_emoji += ""
elif secret_code[i] == "X":
secret_code_emoji += ""
return secret_code_emoji
#compare userGuess with secret code and provide feedback
def compareCodeMMind(secret_code, user_guess):
game_won = False
perfect_pins = 0
wrong_position = 0
msg = ''
#logger.debug("System: MasterMind: secret_code: " + str(secret_code) + " user_guess: " + str(user_guess))
if secret_code == user_guess: #correct guess, user wins
perfect_pins = 4
game_won = True
else:
# check for perfect pins and right color wrong position
temp_code = []
temp_guess = []
for i in range(len(user_guess)): #check for perfect pins
if user_guess[i] == secret_code[i]:
perfect_pins += 1
else:
temp_code.append(secret_code[i])
temp_guess.append(user_guess[i])
for i in range(len(temp_guess)): #check for right color wrong position
for j in range(len(temp_code)):
if temp_guess[i] == temp_code[j]:
wrong_position += 1
temp_code[j] = "0"
break
# display feedback
if game_won:
msg += f"Correct{getEmojiMMind(user_guess)}\n"
else:
msg += f"Guess{getEmojiMMind(user_guess)}\n"
if perfect_pins > 0 and game_won == False:
msg += "✅ color ✅ position: {}".format(perfect_pins)
if wrong_position > 0:
if "" in msg: msg += f"\n"
msg += "✅ color 🚫 position: {}".format(wrong_position)
if "" not in msg and game_won == False:
msg += "🚫No pins in your guess😿 are in the code!"
return msg
#game loop with turn counter
def playGameMMind(diff, secret_code, turn_count, nodeID, message):
msg = ''
won = False
if turn_count <= 10:
user_guess = getGuessMMind(diff, message)
if user_guess == "XXXX":
msg += "Invalid guess. Please enter 4 valid colors."
return msg
check_guess = compareCodeMMind(secret_code, user_guess)
# display turn count and feedback
msg += "Turn {}:".format(turn_count)
if check_guess.startswith("Correct"):
won = True
msg += check_guess
if won == True:
msg += f"\n🎉🧠 you win 🥷🤯"
# get high score
high_score = getHighScoreMMind(nodeID, turn_count, diff)
if high_score != 0:
msg += f"\n🏆 High Score:{high_score[0]['turns']} turns, Difficulty:{high_score[0]['diff'].upper()}"
msg += "\nWould you like to play again?\n(N)ormal, (H)ard, e(X)pert?"
# reset turn count in tracker
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
mindTracker[i]['turns'] = 1
mindTracker[i]['secret_code'] = ''
mindTracker[i]['cmd'] = 'new'
else:
# increment turn count and keep playing
turn_count += 1
# store turn count in tracker
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
mindTracker[i]['turns'] = turn_count
elif won == False:
msg += f"🙉Game Over🙈\nThe code was: {getEmojiMMind(secret_code)}"
msg += "\nYou have run out of turns.😿"
msg += "\nWould you like to play again? (N)ormal, (H)ard, or e(X)pert?"
# reset turn count in tracker
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
mindTracker[i]['turns'] = 1
mindTracker[i]['secret_code'] = ''
mindTracker[i]['cmd'] = 'new'
return msg
def endGameMMind(nodeID):
global mindTracker
# remove player from tracker
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
del mindTracker[i]
logger.debug("System: MasterMind: Player removed: " + str(nodeID))
break
#main game
def start_mMind(nodeID, message):
global mindTracker
last_cmd = ""
msg = ''
# get player's last command from tracker if not new player
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
last_cmd = mindTracker[i]['cmd']
logger.debug("System: MasterMind: last_cmd: " + str(last_cmd))
if last_cmd == "new":
if message.lower().startswith("n") or message.lower().startswith("h") or message.lower().startswith("x"):
diff = message.lower()[0]
else:
diff = "n"
# set player's last command to makeCode
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
mindTracker[i]['cmd'] = 'makeCode'
mindTracker[i]['diff'] = diff
# Return color message to player
msg += chooseDifficultyMMind(message.lower()[0])
return msg
if last_cmd == "makeCode":
# get difficulty from tracker
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
diff = mindTracker[i]['diff']
secret_code = makeCodeMMind(diff)
last_cmd = "playGame"
# set player's last command to playGame
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
mindTracker[i]['cmd'] = 'playGame'
mindTracker[i]['secret_code'] = secret_code
mindTracker[i]['last_played'] = time.time()
if last_cmd == "playGame":
# get difficulty, secret code, and turn count from tracker
for i in range(len(mindTracker)):
if mindTracker[i]['nodeID'] == nodeID:
diff = mindTracker[i]['diff']
secret_code = mindTracker[i]['secret_code']
turn_count = mindTracker[i]['turns']
msg += playGameMMind(diff, secret_code, turn_count, nodeID=nodeID, message=message)
return msg

View File

@@ -94,6 +94,7 @@ try:
# general
useDMForResponse = config['general'].getboolean('respond_by_dm_only', True)
publicChannel = config['general'].getint('defaultChannel', 0) # the meshtastic public channel
ignoreDefaultChannel = config['general'].getboolean('ignoreDefaultChannel', False)
zuluTime = config['general'].getboolean('zuluTime', False) # aka 24 hour time
log_messages_to_file = config['general'].getboolean('LogMessagesToFile', True) # default True
syslog_to_file = config['general'].getboolean('SyslogToFile', False)
@@ -104,6 +105,8 @@ try:
welcome_message = (f"{welcome_message}").replace('\\n', '\n') # allow for newlines in the welcome message
motd_enabled = config['general'].getboolean('motdEnabled', True)
MOTD = config['general'].get('motd', MOTD)
enableCmdHistory = config['general'].getboolean('enableCmdHistory', True)
lheardCmdIgnoreNode = config['general'].get('lheardCmdIgnoreNode', '').split(',')
whoami_enabled = config['general'].getboolean('whoami', True)
dad_jokes_enabled = config['general'].getboolean('DadJokes', False)
solar_conditions_enabled = config['general'].getboolean('spaceWeather', True)
@@ -152,6 +155,8 @@ try:
lemonade_enabled = config['games'].getboolean('lemonade', True)
blackjack_enabled = config['games'].getboolean('blackjack', True)
videoPoker_enabled = config['games'].getboolean('videoPoker', True)
mastermind_enabled = config['games'].getboolean('mastermind', True)
golfSim_enabled = config['games'].getboolean('golfSim', True)
# messaging settings
responseDelay = config['messagingSettings'].getfloat('responseDelay', 0.7) # default 0.7

View File

@@ -45,6 +45,13 @@ if solar_conditions_enabled:
from modules.solarconditions import * # from the spudgunman/meshing-around repo
trap_list = trap_list + trap_list_solarconditions # items hfcond, solar, sun, moon
help_message = help_message + ", sun, hfcond, solar, moon"
else:
hf_band_conditions = False
# Command History Configuration
if enableCmdHistory:
trap_list = trap_list + ("history",)
#help_message = help_message + ", history"
# Location Configuration
if location_enabled:
@@ -58,12 +65,16 @@ if location_enabled:
else:
# NOAA only features
help_message = help_message + ", wxa, tide"
# BBS Configuration
if bbs_enabled:
from modules.bbstools import * # from the spudgunman/meshing-around repo
trap_list = trap_list + trap_list_bbs # items bbslist, bbspost, bbsread, bbsdelete, bbshelp
help_message = help_message + ", bbslist, bbshelp"
else:
bbs_help = False
bbs_list_messages = False
# Dad Jokes Configuration
if dad_jokes_enabled:
@@ -74,7 +85,7 @@ if dad_jokes_enabled:
# Wikipedia Search Configuration
if wikipedia_enabled:
import wikipedia # pip install wikipedia
trap_list = trap_list + ("wiki:",)
trap_list = trap_list + ("wiki:", "wiki?",)
help_message = help_message + ", wiki:"
# LLM Configuration
@@ -106,25 +117,40 @@ if videoPoker_enabled:
from modules.videopoker import * # from the spudgunman/meshing-around repo
trap_list = trap_list + ("videopoker",)
games_enabled = True
if mastermind_enabled:
from modules.mmind import * # from the spudgunman/meshing-around repo
trap_list = trap_list + ("mastermind",)
games_enabled = True
if golfSim_enabled:
from modules.golfsim import * # from the spudgunman/meshing-around repo
trap_list = trap_list + ("golfsim",)
games_enabled = True
# Games Configuration
if games_enabled is True:
help_message = help_message + ", games"
trap_list = trap_list + ("games",)
gTnW_enabled = True
gamesCmdList = "CMD: "
gamesCmdList = "Play via DM🕹 CMD: "
if dopewars_enabled:
gamesCmdList += "DopeWars, "
gamesCmdList += "dopeWars, "
if lemonade_enabled:
gamesCmdList += "LemonStand, "
gamesCmdList += "lemonStand, "
if gTnW_enabled:
import random
trap_list = trap_list + ("globalthermonuclearwar",)
if blackjack_enabled:
gamesCmdList += "BlackJack, "
gamesCmdList += "blackJack, "
if videoPoker_enabled:
gamesCmdList += "VideoPoker, "
gamesCmdList += "videoPoker, "
if mastermind_enabled:
gamesCmdList += "masterMind, "
if golfSim_enabled:
gamesCmdList += "golfSim, "
gamesCmdList = gamesCmdList[:-2] # remove the last comma
else:
gamesCmdList = ""
# Scheduled Broadcast Configuration
if scheduler_enabled:
@@ -573,13 +599,40 @@ def get_wikipedia_summary(search_term):
return summary
def getPrettyTime(seconds):
# convert unix time to minutes, hours, or days, or years for simple display
designator = "s"
if seconds > 0:
seconds = round(seconds / 60)
designator = "m"
if seconds > 60:
seconds = round(seconds / 60)
designator = "h"
if seconds > 24:
seconds = round(seconds / 24)
designator = "d"
if seconds > 365:
seconds = round(seconds / 365)
designator = "y"
return str(seconds) + designator
def messageTrap(msg):
# Check if the message contains a trap word
# Check if the message contains a trap word, this is the first filter for listning to messages
# after this the message is passed to the command_handler in the bot.py which is switch case filter for applying word to function
# Split Message on assumed words spaces m for m = msg.split(" ")
# t in trap_list, built by the config and system.py not the user
message_list=msg.split(" ")
for m in message_list:
for t in trap_list:
# if word in message is in the trap list, return True
if t.lower() == m.lower():
return True
# if no trap words found, run a search for near misses like ping? or cmd?
for m in message_list:
for t in range(len(trap_list)):
if m.endswith('?') and m[:-1].lower() == trap_list[t]:
return True
return False
def exit_handler():

View File

@@ -2,6 +2,7 @@
# Adapted for Meshtastic mesh-bot by K7MHI Kelly Keeton 2024
import random
import time
import pickle
from modules.log import *
vpStartingCash = 20
@@ -54,10 +55,8 @@ def drawCardsVp(*cards, return_string=True):
# "King" should be "K" and "10" should still be "10"
if card.rank == 10: # ten is the only one who's rank is 2 char long
rank = str(card.rank)
space = '' # if we write "10" on the card that line will be 1 char to long
else:
rank = str(card.rank)[0] # some have a rank of 'King' this changes that to a simple 'K' ("King" doesn't fit)
space = ' ' # no "10", we use a blank space to will the void
# get the cards suit in two steps
suit = suits_name.index(card.suit)
suit = suits_symbols[suit]
@@ -232,7 +231,6 @@ class PlayerVP:
if resetHand:
self.bankroll += self.bet_size * payoff[hand_name]
elif 2 in points_repeat: # find pair
logger.debug(f"System: VideoPoker: 235 self.bankroll: {self.bankroll} bet_size: {self.bet_size}")
hand_name = "Pair👯"
if resetHand:
self.bankroll += self.bet_size * payoff[hand_name]
@@ -274,6 +272,30 @@ def setLastCmdVp(nodeID, cmd):
if vpTracker[i]['nodeID'] == nodeID:
vpTracker[i]['cmd'] = cmd
def saveHSVp(nodeID, highScore):
# Save the game high_score to pickle
highScore = {'nodeID': nodeID, 'highScore': highScore}
try:
with open('videopoker_hs.pkl', 'wb') as file:
pickle.dump(highScore, file)
except FileNotFoundError:
logger.debug("System: BlackJack: Creating new videopoker_hs.pkl file")
with open('videopoker_hs.pkl', 'wb') as file:
pickle.dump(highScore, file)
def loadHSVp():
# Load the game high_score from pickle
try:
with open('videopoker_hs.pkl', 'rb') as file:
highScore = pickle.load(file)
return highScore
except FileNotFoundError:
logger.debug("System: VideoPoker: Creating new videopoker_hs.pkl file")
highScore = {'nodeID': 0, 'highScore': 0}
with open('videopoker_hs.pkl', 'wb') as file:
pickle.dump(highScore, file)
return 0
def playVideoPoker(nodeID, message):
msg = ""
@@ -282,7 +304,7 @@ def playVideoPoker(nodeID, message):
# create new player if not in tracker
logger.debug(f"System: VideoPoker: New Player {nodeID}")
vpTracker.append({'nodeID': nodeID, 'cmd': 'new', 'time': time.time(), 'cash': vpStartingCash, 'player': None, 'deck': None, 'highScore': 0, 'drawCount': 0})
return f"Welcome to 🎰 VideoPoker! you have {vpStartingCash} coins, Whats your bet?"
return f"Welcome to 🎰VideoPoker♥️ you have {vpStartingCash} coins, Whats your bet?"
# Gather the player's bet
if getLastCmdVp(nodeID) == "new" or getLastCmdVp(nodeID) == "gameOver":
@@ -346,7 +368,7 @@ def playVideoPoker(nodeID, message):
vpTracker[i]['deck'] = deck
vpTracker[i]['drawCount'] = drawCount
msg += f"\nDeal new card? \nex: 1,3,4 or (N)o,(A)ll"
msg += f"\nDeal new card? \nex: 1,3,4 or (N)o,(A)ll (H)and"
setLastCmdVp(nodeID, "redraw")
return msg
@@ -408,6 +430,8 @@ def playVideoPoker(nodeID, message):
elif player.bankroll > vpTracker[i]['highScore']:
vpTracker[i]['highScore'] = player.bankroll
msg += " 🎉HighScore!"
# save high score
saveHSVp(nodeID, vpTracker[i]['highScore'])
msg += f"\nPlace your Bet, 'L' to leave the game."

View File

@@ -94,10 +94,20 @@ def get_wx_meteo(lat=0, lon=0, unit=0):
code_string = ""
if daily_weather_code[i] == 0:
code_string = "Clear sky"
elif daily_weather_code[i] == 1 or 2 or 3:
code_string = "Partly cloudy"
elif daily_weather_code[i] == 45 or 48:
elif daily_weather_code[i] == 1:
code_string = "Mostly Cloudy"
elif daily_weather_code[i] == 2:
code_string = "Partly Cloudy"
elif daily_weather_code[i] == 3:
code_string = "Overcast"
elif daily_weather_code[i] == 5:
code_string = "Haze"
elif daily_weather_code[i] == 10:
code_string = "Mist"
elif daily_weather_code[i] == 45:
code_string = "Fog"
elif daily_weather_code[i] == 48:
code_string = "Freezing Fog"
elif daily_weather_code[i] == 51:
code_string = "Drizzle: Light"
elif daily_weather_code[i] == 53:
@@ -126,6 +136,10 @@ def get_wx_meteo(lat=0, lon=0, unit=0):
code_string = "Snow: Heavy"
elif daily_weather_code[i] == 77:
code_string = "Snow Grains"
elif daily_weather_code[i] == 78:
code_string = "Ice Crystals"
elif daily_weather_code[i] == 79:
code_string = "Ice Pellets"
elif daily_weather_code[i] == 80:
code_string = "Rain showers: Slight"
elif daily_weather_code[i] == 81:
@@ -133,15 +147,17 @@ def get_wx_meteo(lat=0, lon=0, unit=0):
elif daily_weather_code[i] == 82:
code_string = "Rain showers: Heavy"
elif daily_weather_code[i] == 85:
code_string = "Snow showers: Light"
code_string = "Snow showers"
elif daily_weather_code[i] == 86:
code_string = "Snow showers: Moderate"
code_string = "Snow showers: Heavy"
elif daily_weather_code[i] == 95:
code_string = "Thunderstorm: Slight"
code_string = "Thunderstorm"
elif daily_weather_code[i] == 96:
code_string = "Thunderstorm: Moderate"
code_string = "Hailstorm"
elif daily_weather_code[i] == 97:
code_string = "Thunderstorm Heavy"
elif daily_weather_code[i] == 99:
code_string = "Thunderstorm: Heavy"
code_string = "Hailstorm Heavy"
weather_report += "Cond: " + code_string + ". "

View File

@@ -8,7 +8,7 @@ from pubsub import pub # pip install pubsub
from modules.log import *
from modules.system import *
responseDelay = 0.7 # delay in seconds for response to avoid message collision
DEBUGpacket = False # Debug print the packet rx
def auto_response(message, snr, rssi, hop, message_from_id, channel_number, deviceID):
# Auto response to messages
@@ -117,8 +117,18 @@ def onReceive(packet, interface):
# extract interface defailts from interface object
rxType = type(interface).__name__
rxNode = 0
# Debug print the interface object
#for item in interface.__dict__.items(): print (item)
message_from_id = 0
snr = 0
rssi = 0
hop = 0
hop_away = 0
if DEBUGpacket:
# Debug print the interface object
for item in interface.__dict__.items(): intDebug = f"{item}\n"
logger.debug(f"System: Packet Received on {rxType} Interface\n {intDebug} \n END of interface \n")
# Debug print the packet for debugging
logger.debug(f"Packet Received\n {packet} \n END of packet \n")
if rxType == 'SerialInterface':
rxInterface = interface.__dict__.get('devPath', 'unknown')
@@ -140,13 +150,7 @@ def onReceive(packet, interface):
elif interface2_enabled and interface2_type == 'ble':
rxNode = 2
# Debug print the packet for debugging
#print(f"Packet Received\n {packet} \n END of packet \n")
message_from_id = 0
# check for a message packet and process it
snr = 0
rssi = 0
try:
if 'decoded' in packet and packet['decoded']['portnum'] == 'TEXT_MESSAGE_APP':
message_bytes = packet['decoded']['payload']
@@ -281,13 +285,13 @@ async def start_rx():
logger.info(f"System: Autoresponder Started for Device2 {get_name_from_number(myNodeNum2, 'long', 2)},"
f"{get_name_from_number(myNodeNum2, 'short', 2)}. NodeID: {myNodeNum2}, {decimal_to_hex(myNodeNum2)}")
if log_messages_to_file:
logger.debug(f"System: Logging Messages to disk")
logger.debug("System: Logging Messages to disk")
if sentry_enabled:
logger.debug(f"System: Sentry Enabled")
logger.debug("System: Sentry Enabled")
if store_forward_enabled:
logger.debug(f"System: Store and Forward Enabled using limit: {storeFlimit}")
if useDMForResponse:
logger.debug(f"System: Respond by DM only")
logger.debug("System: Respond by DM only")
if repeater_enabled and interface2_enabled:
logger.debug(f"System: Repeater Enabled for Channels: {repeater_channels}")
if radio_detection_enabled: