mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Moved link_formatter function to misc module
This commit is contained in:
parent
5d0758f32d
commit
f010832269
8
misc.py
8
misc.py
|
@ -1,6 +1,7 @@
|
|||
import json, logging, sys
|
||||
import json, logging, sys, re
|
||||
|
||||
# Create a custom logger
|
||||
|
||||
misc_logger = logging.getLogger("rcgcdw.misc")
|
||||
|
||||
data_template = {"rcid": 99999999999,
|
||||
|
@ -44,3 +45,8 @@ def save_datafile(data):
|
|||
def weighted_average(value, weight, new_value):
|
||||
"""Calculates weighted average of value number with weight weight and new_value with weight 1"""
|
||||
return round(((value * weight) + new_value) / (weight + 1), 2)
|
||||
|
||||
|
||||
def link_formatter(link):
|
||||
"""Formats a link to not embed it"""
|
||||
return "<"+re.sub(r"([ \)])", "\\\\\\1", link)+">"
|
|
@ -20,12 +20,14 @@
|
|||
# WARNING! SHITTY CODE AHEAD. ENTER ONLY IF YOU ARE SURE YOU CAN TAKE IT
|
||||
# You have been warned
|
||||
|
||||
import time, logging, logging.config, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys, ipaddress, misc
|
||||
import time, logging.config, json, requests, datetime, re, gettext, math, random, os.path, schedule, sys, ipaddress, misc
|
||||
from bs4 import BeautifulSoup
|
||||
from collections import defaultdict, Counter
|
||||
from urllib.parse import quote_plus
|
||||
from html.parser import HTMLParser
|
||||
|
||||
from misc import link_formatter
|
||||
|
||||
if __name__ != "__main__": # return if called as a module
|
||||
logging.critical("The file is being executed as a module. Please execute the script using the console.")
|
||||
sys.exit(1)
|
||||
|
@ -171,9 +173,6 @@ def send_to_discord(data):
|
|||
time.sleep(2.0)
|
||||
pass
|
||||
|
||||
def link_formatter(link):
|
||||
return "<"+re.sub(r"([ \)])", "\\\\\\1", link)+">"
|
||||
|
||||
def compact_formatter(action, change, parsed_comment, categories):
|
||||
if action != "suppressed":
|
||||
author_url = link_formatter("https://{wiki}.gamepedia.com/User:{user}".format(wiki=settings["wiki"], user=change["user"]))
|
||||
|
|
Loading…
Reference in a new issue