Compare commits
2 Commits
68811b1b6e
...
8c5208a0f0
Author | SHA1 | Date | |
---|---|---|---|
8c5208a0f0
|
|||
42256b211d
|
@ -12,7 +12,7 @@ You can also append it with `|<string>` to pass through any reminder to the noti
|
|||||||
Cronjob to execute every 6 hours, 10 minutes past the hour:
|
Cronjob to execute every 6 hours, 10 minutes past the hour:
|
||||||
|
|
||||||
```
|
```
|
||||||
10 */6 * * * cd /root/wqb && /usr/bin/python wqb.py
|
10 3,9,15,21 * * * cd /root/wqb && /usr/bin/python wqb.py
|
||||||
```
|
```
|
||||||
|
|
||||||
# Master Tamer/Pet lists
|
# Master Tamer/Pet lists
|
||||||
@ -54,7 +54,6 @@ Durian Strongfruit|Training with Durian
|
|||||||
Ruinhoof|Ruinhoof
|
Ruinhoof|Ruinhoof
|
||||||
Deathscreech|Deathscreech
|
Deathscreech|Deathscreech
|
||||||
Corrupted Blood of Argus|Corrupted Blood of Argus
|
Corrupted Blood of Argus|Corrupted Blood of Argus
|
||||||
Watcher|Watcher
|
|
||||||
Minixis|Minixis
|
Minixis|Minixis
|
||||||
Foulclaw|Foulclaw
|
Foulclaw|Foulclaw
|
||||||
Retch|Retch
|
Retch|Retch
|
||||||
|
73
wqb.py
73
wqb.py
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import urllib2
|
import urllib2
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
logging.basicConfig(filename='wqb.log', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', encoding='utf-8', level=logging.DEBUG)
|
logging.basicConfig(filename='wqb.log', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', encoding='utf-8', level=logging.DEBUG)
|
||||||
|
|
||||||
@ -17,6 +18,9 @@ token = config[1].split('=')[1].strip()
|
|||||||
def send_message(input):
|
def send_message(input):
|
||||||
data = {
|
data = {
|
||||||
'chat_id': chat_id,
|
'chat_id': chat_id,
|
||||||
|
'parse_mode': "MarkdownV2",
|
||||||
|
'disable_web_page_preview': 'true',
|
||||||
|
'disable_notification': 'true',
|
||||||
'text': input
|
'text': input
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,30 +31,55 @@ def send_message(input):
|
|||||||
|
|
||||||
logging.info('sent message ' + input)
|
logging.info('sent message ' + input)
|
||||||
|
|
||||||
|
def get_id(quest):
|
||||||
|
sources = {'SL': sl, 'BfA': bfa, 'Legion': legion}
|
||||||
|
|
||||||
|
for name, src in sources.items():
|
||||||
|
if (src.find(quest) != -1):
|
||||||
|
rgx = r"\"(\d+)\":{\"name_enus\":\"" + re.escape(quest) + r"\""
|
||||||
|
m = re.search(rgx, src)
|
||||||
|
if (m):
|
||||||
|
return m.group(1), name
|
||||||
|
else:
|
||||||
|
return 0, name
|
||||||
|
|
||||||
|
return -1, ''
|
||||||
|
|
||||||
|
def sanitize(str):
|
||||||
|
return str.replace('-', '\\-')
|
||||||
|
|
||||||
qlist = open('ql','r')
|
qlist = open('ql','r')
|
||||||
qlist = qlist.readlines()
|
qlist = qlist.readlines()
|
||||||
|
output = ''
|
||||||
|
|
||||||
for quest in qlist:
|
for quest in qlist:
|
||||||
quest = quest.rstrip()
|
qsplit = quest.rstrip().split('|')
|
||||||
qsplit = quest.split('|')
|
id = -1
|
||||||
if len(qsplit) == 2:
|
tag = ''
|
||||||
if (sl.find(qsplit[1]) != -1):
|
q = ''
|
||||||
send_message('[SL Tamer] ' + qsplit[0] + ' - ' + qsplit[1])
|
prefix = ''
|
||||||
if (bfa.find(qsplit[1]) != -1):
|
suffix = ''
|
||||||
send_message('[BFA Tamer] ' + qsplit[0] + ' - ' + qsplit[1])
|
|
||||||
if (legion.find(qsplit[1]) != -1):
|
if len(qsplit) == 1:
|
||||||
send_message('[Legion Tamer] ' + qsplit[0] + ' - ' + qsplit[1])
|
q = qsplit[0]
|
||||||
|
elif len(qsplit) == 2:
|
||||||
|
q = qsplit[1]
|
||||||
|
prefix = qsplit[0] + " - "
|
||||||
elif len(qsplit) == 3:
|
elif len(qsplit) == 3:
|
||||||
if (sl.find(qsplit[1]) != -1):
|
q = qsplit[1]
|
||||||
send_message('[SL Tamer] ' + qsplit[0] + ' - ' + qsplit[1] + ' - ' + qsplit[2])
|
prefix = qsplit[0] + " - "
|
||||||
if (bfa.find(qsplit[1]) != -1):
|
suffix = " - " + qsplit[2]
|
||||||
send_message('[BFA Tamer] ' + qsplit[0] + ' - ' + qsplit[1] + ' - ' + qsplit[2])
|
|
||||||
if (legion.find(qsplit[1]) != -1):
|
r = get_id(q)
|
||||||
send_message('[Legion Tamer] ' + qsplit[0] + ' - ' + qsplit[1] + ' - ' + qsplit[2])
|
id = r[0]
|
||||||
else:
|
tag = r[1]
|
||||||
if (sl.find(quest) != -1):
|
if (id == -1):
|
||||||
send_message('[SL] ' + quest)
|
continue
|
||||||
if (bfa.find(quest) != -1):
|
elif (id > 0):
|
||||||
send_message('[BFA] ' + quest)
|
q = "[%s](https://wowhead.com/quest=%s)" % (q, id)
|
||||||
if (legion.find(quest) != -1):
|
|
||||||
send_message('[Legion] ' + quest)
|
output = "%s\n\\[%s\\] %s%s%s" % (output, tag, prefix, q, suffix)
|
||||||
|
|
||||||
|
if output != '':
|
||||||
|
output = sanitize(output)
|
||||||
|
send_message(output.strip())
|
||||||
|
Reference in New Issue
Block a user