Skip to content

Commit

Permalink
Add Windows compatibility (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
eibex authored Feb 15, 2020
1 parent 63443fa commit d7f753b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.1.0
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Reaction Light - Changelog
### 0.1.0
- Add Windows compatibility

### 0.0.7
- Add system channel updating via Discord (using the `rl!systemchannel` command)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reaction Light - Discord Role Bot
![Reaction Light 0.0.7](https://img.shields.io/badge/Reaction%20Light-0.0.7-yellow.svg)
![Reaction Light 0.1.0](https://img.shields.io/badge/Reaction%20Light-0.1.0-yellow.svg)
![Python 3.5.3+](https://img.shields.io/badge/python-3.5.3+-blue.svg)
![discord.py rewrite](https://img.shields.io/badge/discord.py-1.2.5+-blue.svg)

Expand Down
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@


# Original Repository: https://github.com/eibex/reaction-light
__author__ = "eibex"
__version__ = "0.0.7"
__license__ = "MIT"
# License: MIT - Copyright 2019-2020 eibex

__version__ = "0.1.0"

directory = path.dirname(path.realpath(__file__))
folder = f"{directory}/files"
Expand Down
25 changes: 14 additions & 11 deletions rlightfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from os import path
import csv

# Original Repository: https://github.com/eibex/reaction-light
# License: MIT - Copyright 2019-2020 eibex

folder = f"{path.dirname(path.realpath(__file__))}/files"
wizard = {}
wizardcache = {}
Expand All @@ -13,7 +16,7 @@ def readcache():
# Reads cache.csv and stores into the dictionary
# Run at the start of the program and updated when changes are made
try:
with open(f"{folder}/cache.csv", "r") as f:
with open(f"{folder}/cache.csv", "r", encoding="utf-8") as f:
read = csv.reader(f, delimiter=",")
for row in read:
cache[row[0]] = row[1]
Expand Down Expand Up @@ -42,15 +45,15 @@ def getch(r):

def getcombo(r):
# Returns the reaction-role combinations
with open(f"{folder}/{r}.csv", "r") as f:
with open(f"{folder}/{r}.csv", "r", encoding="utf-8") as f:
read = csv.reader(f, delimiter=",")
return [i for i in read]


def addids(message_id, r):
# Adds the embed ID and CSV filename to the cache
with open(f"{folder}/cache.csv", "a") as f:
w = csv.writer(f, delimiter=",")
with open(f"{folder}/cache.csv", "a", encoding="utf-8") as f:
w = csv.writer(f, delimiter=",", lineterminator="\n")
w.writerow([message_id, r])


Expand All @@ -63,7 +66,7 @@ def getids(message_id):

def getreactions(r):
# Returns a list of the reactions used by a certain embed
with open(f"{folder}/{r}.csv", "r") as f:
with open(f"{folder}/{r}.csv", "r", encoding="utf-8") as f:
read = csv.reader(f, delimiter=",")
reactions = {}
for row in read:
Expand All @@ -82,7 +85,7 @@ def listen(user, channel):
ids = {}

try:
with open(f"{folder}/id.csv", "r") as f:
with open(f"{folder}/id.csv", "r", encoding="utf-8") as f:
read = csv.reader(f, delimiter=",")
for i in read:
ids[i[0]] = i[1:]
Expand All @@ -92,8 +95,8 @@ def listen(user, channel):
print("Creating id.csv")

ids[r] = [str(user), str(channel)]
with open(f"{folder}/id.csv", "w") as f:
w = csv.writer(f, delimiter=",")
with open(f"{folder}/id.csv", "w", encoding="utf-8") as f:
w = csv.writer(f, delimiter=",", lineterminator="\n")
for i in ids:
row = [i, ids[i][0], ids[i][1]]
w.writerow(row)
Expand All @@ -119,8 +122,8 @@ def step2(r, role, emoji, done=False):
global wizardcache
if done:
wizard[r][3] += 1 # Set step3 (was 2)
with open(f"{folder}/{r}.csv", "a") as f:
w = csv.writer(f, delimiter=",")
with open(f"{folder}/{r}.csv", "a", encoding="utf-8") as f:
w = csv.writer(f, delimiter=",", lineterminator="\n")
for i in wizardcache[r]:
w.writerow(i)
print("Done adding combos and saved.")
Expand All @@ -135,7 +138,7 @@ def edit(role_channel):
r_ids = {}
for msg_id in cache:
r = cache[msg_id]
with open(f"{folder}/{r}.csv", "r") as f:
with open(f"{folder}/{r}.csv", "r", encoding="utf-8") as f:
read = csv.reader(f, delimiter=",")
for row in read:
channel = int(row[0])
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import configparser

# Original Repository: https://github.com/eibex/reaction-light
# License: MIT - Copyright 2019-2020 eibex
print("Author: eibex")
print("Version: 0.0.7")
print("Version: 0.1.0")
print("License: MIT\n")

print("### ### Reaction Light Setup ### ###")
Expand Down

0 comments on commit d7f753b

Please sign in to comment.