mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Merge branch 'testing' into 'master'
Critical fix See merge request piotrex43/RcGcDw!1
This commit is contained in:
commit
69e151b8c8
30
README.md
30
README.md
|
@ -16,24 +16,24 @@ Recent changes Gamepedia compatible Discord webhook is a project made from earli
|
||||||
|
|
||||||
### settings.json ###
|
### settings.json ###
|
||||||
Explanation for settings:
|
Explanation for settings:
|
||||||
`cooldown` – interval for how often changes are retrieved from the wiki (due to used solutions, the real interval is ~1 sec longer)
|
`cooldown` – interval for how often changes are retrieved from the wiki (due to used solutions, the real interval is ~1 sec longer).
|
||||||
`wiki` – wiki prefix the bot is supposed to work with (for example, for English Minecraft Wiki it's minecraft (https://**minecraft**.gamepedia.com) and for Polish Minecraft Wiki minecraft-pl (https://**minecraft-pl**.gamepedia.com
|
`wiki` – wiki prefix the bot is supposed to work with (for example, for English Minecraft Wiki it's minecraft (https://**minecraft**.gamepedia.com) and for Polish Minecraft Wiki minecraft-pl (https://**minecraft-pl**.gamepedia.com)
|
||||||
`lang` – language for the messages, currently available options are: de, en, fr, pl
|
`lang` – language for the messages, currently available options are: de, en, fr, pl.
|
||||||
`header` – it's recommended to leave this value as it is, it's a header the script will use to communicate with Gamepedia. Please note that without it, no communication will be possible.
|
`header` – it's recommended to leave this value as it is, it's a header the script will use to communicate with Gamepedia. Please note that without it, no communication will be possible.
|
||||||
`limit` – amount of actions retrieved every `cooldown` amount of seconds. The higher it is the more network data will be used and the data will be processed longer, setting it to higher values is not recommended unless cooldown value is higher.
|
`limit` – amount of actions retrieved every `cooldown` amount of seconds. The higher it is the more network data will be used and the data will be processed longer, setting it to higher values is not recommended unless cooldown value is higher it also cannot be higher than 500.
|
||||||
`webhookURL` – webhook URL you can get using [channel settings in Discord](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
|
`webhookURL` – webhook URL you can get using [channel settings in Discord](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks).
|
||||||
`limitrefetch` – limit of how many changes can be retrieved when refetch happens, cannot be lower than limit. -1 if you want to disable auto-refetch
|
`limitrefetch` – limit of how many changes can be retrieved when refetch happens, cannot be lower than limit. -1 if you want to disable auto-refetch. Value cannot be higher than 500.
|
||||||
`wikiname` – a name of the wiki the bot will work on, required in some messages
|
`wikiname` – a name of the wiki the bot will work on, required in some messages.
|
||||||
`avatars` – this section makes specific types of messages overwrite the default webhook avatar
|
`avatars` – this section makes specific types of messages overwrite the default webhook avatar.
|
||||||
* `connection_failed` – message printed when script fails connection with the wiki several times
|
* `connection_failed` – message printed when script fails connection with the wiki several times.
|
||||||
* `no_event` – error message when the event couldn't be recognized by the script
|
* `no_event` – error message when the event couldn't be recognized by the script.
|
||||||
* `embed` – every embed message showing changes
|
* `embed` – every embed message showing changes.
|
||||||
|
|
||||||
`verbose_level` – a number (min 0, max 50) identifying the type of messages that will be written into the console. (CRITICAL 50, ERROR 40, WARNING 30, INFO 20, DEBUG 10)
|
`verbose_level` – a number (min 0, max 50) identifying the type of messages that will be written into the console. (CRITICAL 50, ERROR 40, WARNING 30, INFO 20, DEBUG 10).
|
||||||
`show_updown_messages` – bool value, depending on this settings the messages whenever the wiki goes up and down will be sent to the channel
|
`show_updown_messages` – bool value, depending on this settings the messages whenever the wiki goes up and down will be sent to the channel.
|
||||||
`appearience` – section with different types of actions and logs, and corresponding to them colors/icons. In here you can set custom icon or color!
|
`appearience` – section with different types of actions and logs, and corresponding to them colors/icons. In here you can set custom icon or color!
|
||||||
`overview` – bool value, sends a day overview to the channel if true
|
`overview` – bool value, sends a day overview to the channel if true.
|
||||||
`overview_time` – **local machine time** at which the day overview will be sent
|
`overview_time` – **local machine time** at which the day overview will be sent.
|
||||||
|
|
||||||
### How to use ###
|
### How to use ###
|
||||||
Make sure you have installed all of dependencies and **filled settings.json properly**. You can also use `pip install -r requirements.txt` to install dependencies automatically. If you are using Raspberry Pi you won't have newest Python version installed, you can use [this guide](https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f).
|
Make sure you have installed all of dependencies and **filled settings.json properly**. You can also use `pip install -r requirements.txt` to install dependencies automatically. If you are using Raspberry Pi you won't have newest Python version installed, you can use [this guide](https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f).
|
||||||
|
|
11
rcgcdw.py
11
rcgcdw.py
|
@ -32,7 +32,7 @@ with open("settings.json") as sfile:
|
||||||
logging.basicConfig(level=settings["verbose_level"])
|
logging.basicConfig(level=settings["verbose_level"])
|
||||||
if settings["limitrefetch"] != -1 and os.path.exists("lastchange.txt") == False:
|
if settings["limitrefetch"] != -1 and os.path.exists("lastchange.txt") == False:
|
||||||
with open("lastchange.txt", 'w') as sfile:
|
with open("lastchange.txt", 'w') as sfile:
|
||||||
sfile.write("")
|
sfile.write("99999999999")
|
||||||
logging.info("Current settings: {settings}".format(settings=settings))
|
logging.info("Current settings: {settings}".format(settings=settings))
|
||||||
if settings["lang"] != "en" or settings["lang"] == "":
|
if settings["lang"] != "en" or settings["lang"] == "":
|
||||||
lang = gettext.translation('rcgcdw', localedir='locale', languages=[settings["lang"]])
|
lang = gettext.translation('rcgcdw', localedir='locale', languages=[settings["lang"]])
|
||||||
|
@ -531,8 +531,13 @@ class recent_changes_class(object):
|
||||||
clock = 0
|
clock = 0
|
||||||
if settings["limitrefetch"] != -1:
|
if settings["limitrefetch"] != -1:
|
||||||
with open("lastchange.txt", "r") as record:
|
with open("lastchange.txt", "r") as record:
|
||||||
file_id = int(record.read().strip())
|
file_content = record.read().strip()
|
||||||
|
if file_content:
|
||||||
|
file_id = int(file_content)
|
||||||
logging.debug("File_id is {val}".format(val=file_id))
|
logging.debug("File_id is {val}".format(val=file_id))
|
||||||
|
else:
|
||||||
|
logging.debug("File is empty")
|
||||||
|
file_id = 999999999
|
||||||
else:
|
else:
|
||||||
file_id = 999999999 #such value won't cause trouble, and it will make sure no refetch happens
|
file_id = 999999999 #such value won't cause trouble, and it will make sure no refetch happens
|
||||||
def add_cache(self, change):
|
def add_cache(self, change):
|
||||||
|
@ -575,7 +580,7 @@ class recent_changes_class(object):
|
||||||
logging.debug("Rejected {val}".format(val=change["rcid"]))
|
logging.debug("Rejected {val}".format(val=change["rcid"]))
|
||||||
continue
|
continue
|
||||||
first_pass(change)
|
first_pass(change)
|
||||||
time.sleep(1.0)
|
time.sleep(3.0) #sadly, the time here needs to be quite high, otherwise we are being rate-limited by the Discord, especially during re-fetch
|
||||||
return change["rcid"]
|
return change["rcid"]
|
||||||
def safe_request(self, url):
|
def safe_request(self, url):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue