Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Signalbot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frederic Aust
Signalbot
Commits
f9d886d3
Commit
f9d886d3
authored
3 years ago
by
Frederic Aust
Browse files
Options
Downloads
Patches
Plain Diff
Datei aufgeräumt
parent
1b85ea36
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
signalbot.py
+1
-83
1 addition, 83 deletions
signalbot.py
with
1 addition
and
83 deletions
signalbot.py
+
1
−
83
View file @
f9d886d3
...
...
@@ -26,10 +26,9 @@ from mod_tex import ModuleTex
from
mod_eventreminder
import
ModuleEventReminder
from
mod_today
import
ModuleToday
# @TODO README Schreiben mit signal-cli Raspberry Pi Installationsanleitung + signal-cli Systembus Einrichtung + Systemd für den Signalbot
# @TODO Einfacher Wrapper zum senden von Nachrichten per shell
# @TODO Config Programm bot-config.py mit dem allgemeine Einstellungen wie Profilname oder Profilbild angepasst werden können
# --> Bot umbenennen evtl in den Bot Emoji
# create logger
log
=
logging
.
getLogger
(
'
signalbot
'
)
...
...
@@ -48,13 +47,6 @@ fh.setFormatter(formatter)
# add handlers to logger
log
.
addHandler
(
fh
)
### how to use your logger ###
# logger.info('info message')
# logger.warning('warn message')
# logger.error('error message')
# logger.critical('critical message')
# logger.debug('debug message')
# load modules
gn
=
None
quotes
=
None
...
...
@@ -161,80 +153,6 @@ def handle_action(timestamp, source, groupID, message, attachments):
log
.
critical
(
f
'
Unknown error:
"
{
ex
}
"
, timestamp=
"
{
timestamp
}
"
, source=
"
{
source
}
"
, groupID=
"
{
groupID
}
"
,
'
f
'
message=
"
{
message
}
"
, attachments=
"
{
attachments
}
"'
)
########
'''
try:
message = message[1:].strip()
msg_splitted = message.split(
"
"
)
action = msg_splitted[0].lower()
if len(action) == 0:
return
if action in [
"
help
"
,
"
list
"
]:
help_func(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]).strip(), groupInfo)
elif action ==
"
remusfeinste
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
remus_feinste(receiver)
elif action ==
"
trueamerican
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
true_american(receiver)
elif (action ==
"
yesno
"
or action ==
"
yn
"
) and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
yes_no_wtf(receiver, action)
elif action ==
"
dadjoke
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
dadjoke(receiver)
elif action ==
"
links
"
and (groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
links(receiver, groupInfo)
elif action in FUN_DICT:
echo(action, receiver)
elif (action in [
"
savequote
"
,
"
addquote
"
,
"
createquote
"
]) and (
groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
save_quote(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]), groupInfo)
elif action ==
"
randomquote
"
and (groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
random_quote(receiver, groupInfo)
elif action ==
"
credits
"
:
credits(receiver)
elif action ==
"
freegames
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
free_games(receiver)
elif (action ==
"
gn
"
or action ==
"
genderneutral
"
) and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
genderneutral(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]))
elif (action ==
"
schlücke
"
or action ==
"
sips
"
) and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
sips(receiver)
elif action ==
"
roll
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
roll(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]))
elif action ==
"
request
"
:
request(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]))
elif action ==
"
challenge
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
get_random_challenge(receiver)
elif action in [
"
savebirthday
"
,
"
addbirthday
"
,
"
createbirthday
"
] and (
groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
save_birthday(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]), groupInfo)
elif action ==
"
allbirthdays
"
and (groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
get_all_birthdays(receiver, groupInfo)
elif action ==
"
nextbirthday
"
and (groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
get_next_birthday(receiver, groupInfo)
elif action in [
"
saveevent
"
,
"
addevent
"
,
"
createevent
"
] and (
groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
save_event(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]), groupInfo)
elif action ==
"
allevents
"
and (groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
get_all_events(receiver, groupInfo)
elif action ==
"
nextevent
"
and (groupInfo is not None and action in groupInfo[
"
COMMANDS
"
]):
get_next_event(receiver, groupInfo)
elif action ==
"
tex
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
get_tex_formula(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]))
elif action ==
"
deepl
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
get_deepl_translation(receiver,
"
"
.join(str(x) for x in msg_splitted[1:]))
elif action ==
"
kingscup
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
get_kings_cup(receiver)
elif action ==
"
today
"
and (groupInfo is None or action in groupInfo[
"
COMMANDS
"
]):
get_today(receiver)
else:
unknown_command(receiver,
message) # wenn nicht berechtigt, dann
"
ich seh nix, ich weiss nix, ich hör nix
"
=> unbekannter befehl
except Exception as ex:
log.critical(f
'
Unknown error:
"
{ex}
"
, timestamp=
"
{timestamp}
"
, source=
"
{source}
"
, groupID=
"
{groupID}
"
,
'
f
'
message=
"
{message}
"
, attachments=
"
{attachments}
"'
)
'''
def
send
(
message
,
receiver
):
if
not
receiver
:
return
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment