some more changes ...

This commit is contained in:
jnoack@itsblue.de 2019-02-06 17:58:33 +01:00
parent 6369ef3f52
commit 84a7065cbd
1 changed files with 798 additions and 796 deletions

View File

@ -1,5 +1,6 @@
#!/usr/local/bin/python3
#!/usr/bin/python3
# this script is added to auto start of the pi zero in /etc/profiles ...
# this is the telegram version ... created with the @botFather of telegram
# bot name: bully3
@ -28,7 +29,7 @@ my_interpret1 = "unknownart1"
my_song2 = "unknownsong2"
my_interpret2 = "unknownart2"
test = True
test = False
if test:
# bully4
@ -97,6 +98,7 @@ def telegram_ahoy_reply(body):
global nextchecktime
global starttime
global auto_check_for_is1_is2
global send_false_alarms
if (re.search("^list$", body, re.IGNORECASE) is not None) | (re.search("^l$", body, re.IGNORECASE) is not None):
soup_page(15)
@ -156,7 +158,7 @@ def telegram_ahoy_reply(body):
if send_false_alarms:
message = message + "Sending false alarms: ON\n"
else:
message = message + "Sending false alarms: ON\n"
message = message + "Sending false alarms: OFF\n"
message = message + "Last overall checktime: " + fullcurrenttime + "\n"
message = message + "Last automatic checktime: " + lastwwwparsetime + "\n"
message = message + "Next checktime: " + nextchecktime + "\n"
@ -180,26 +182,25 @@ def telegram_ahoy_reply(body):
message = message + "SWITCHED ON now."
else:
if re.search("^m", body, re.IGNORECASE):
message = "Sending even false alarms:\n"
if send_false_alarms:
send_false_alarms = False
message = message + "SWITCHED OFF now."
else:
send_false_alarms = True
message = message + "SWITCHED ON now."
message = "Sending even false alarms:\n"
if send_false_alarms:
send_false_alarms = False
message = message + "SWITCHED OFF now."
else:
send_false_alarms = True
message = message + "SWITCHED ON now."
else:
message = "Send: \n\n'list' or 'l' for latest playlist.\n '?' for songs/title looking for.\n 's1=songname' to change song1.\n"
message = message + " 'i1=artist' to change interpret1.\n 's2=songname' to change song2.\n 'i2=artist' to change interpret2.\n"
message = message + " 'is1=artist,song to change #1 \n 'is2=artist,song to change #2 \n "
message = message + " 'w' write i&s to file.\n 'r' read i&s from file\n"
message = message + " 'f' shows found songs.\n 'c' clears list with found songs\n"
message = message + " 's' shows statistics.\n 'g' gets song1,2 and interprets1,2\n"
message = message + " 'a' toggle auto get is1,is2\n 'm' toggle false alarms\n"
else:
message = "Send: \n\n'list' or 'l' for latest playlist.\n '?' for songs/title looking for.\n 's1=songname' to change song1.\n"
message = message + " 'i1=artist' to change interpret1.\n 's2=songname' to change song2.\n 'i2=artist' to change interpret2.\n"
message = message + " 'is1=artist,song to change #1 \n 'is2=artist,song to change #2 \n "
message = message + " 'w' write i&s to file.\n 'r' read i&s from file\n"
message = message + " 'f' shows found songs.\n 'c' clears list with found songs\n"
message = message + " 's' shows statistics.\n 'g' gets song1,2 and interprets1,2\n"
message = message + " 'a' toggle auto get is1,is2\n 'm' toggle false alarms\n"
return message
def write_to_file():
global file_name
global song1, interpret1, song2, interpret2
@ -487,7 +488,7 @@ def remove_signs_from_string(string):
string = string.replace("´", "")
string = string.replace("", "")
string = re.sub(' +', ' ', string)
string = string.strip()
string = string.strip(" ")
return string
def soup_2songs_page():
@ -542,13 +543,13 @@ def soup_2songs_page():
isstr = re.search(" *(.+?) *: *(.+?)$", item_text)
if isstr:
if is_nr == 1:
iinterpret1 = isstr.group(1)
isong1 = isstr.group(2)
iinterpret1 = remove_signs_from_string(isstr.group(1))
isong1 = remove_signs_from_string(isstr.group(2))
#print("Interpret1 '" + iinterpret1 + "' - Song1 '" + isong1 + "'")
is_nr = is_nr + 1
elif is_nr == 2 :
iinterpret2 = isstr.group(1)
isong2 = isstr.group(2)
iinterpret2 = remove_signs_from_string(isstr.group(1))
isong2 = remove_signs_from_string(isstr.group(2))
#print("Interpret2 '" + iinterpret2 + "' - Song2 '" + isong2 + "'")
is_nr = is_nr + 1
if parse_error == True:
@ -780,14 +781,15 @@ bully3_bot = telegram.Bot(telegram_token)
if __name__ == "__main__":
try:
scanwwthread = scanThread(1,"parse_www")
scanwwthread.start()
telegramthread = telegramThread(1,"telegram_bot")
telegramthread.start()
scanwwthread = scanThread(1,"parse_www")
scanwwthread.start()
except KeyboardInterrupt:
print("Detected CTRL-C ... stopping the process. Please wait ...\n")
run_thread = 0
wait(10)
scanwwthread.join()
telegramthread.join()
sys.exit()