diff --git a/README.md b/README.md
index 745ca3a..76e137b 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,8 @@ Use the `credentials.example.py` as a template.
### 2. Create configuration.py (optional)
-Use the `configuration.example.py` as a template.
+Use the `configuration.example.py` as templates. Place each `configuration.py` in the same directory as the
+`configuration.example.py`.
### Example
@@ -48,7 +49,7 @@ bot.exit()
## Modules
The project used to be limited to the `TS3Bot` and `TS3Query` classes but as I worked on it,
-I added modules I thought others would want to use as well, especially the `move_afk` module.
+I added modules I thought others would want to use as well, especially the `afk_mover` module.
The other modules - namely `time_tracker`, `reminder`, `doodle` and `wordpress` -
are rather specific for my circle of friends' TS3 server:
diff --git a/Channel.py b/channel.py
similarity index 100%
rename from Channel.py
rename to channel.py
diff --git a/Client.py b/client.py
similarity index 90%
rename from Client.py
rename to client.py
index 168ecc9..41e5f10 100644
--- a/Client.py
+++ b/client.py
@@ -1,4 +1,4 @@
-from configuration import IDLE_MINUTES_BEFORE_MOVE, AFK_CHANNELS
+from configuration import IDLE_MINUTES_BEFORE_AFK, AFK_CHANNELS
class Client:
@@ -25,10 +25,10 @@ def is_afk(self):
idle_minutes = self.idle_time / 60
- if idle_minutes > IDLE_MINUTES_BEFORE_MOVE or self.is_away:
+ if idle_minutes > IDLE_MINUTES_BEFORE_AFK or self.is_away:
return True
- return self.is_muted and idle_minutes > IDLE_MINUTES_BEFORE_MOVE / 2
+ return self.is_muted and idle_minutes > IDLE_MINUTES_BEFORE_AFK / 2
@property
def is_muted(self):
diff --git a/configuration.example.py b/configuration.example.py
index d6315c1..c545ac6 100644
--- a/configuration.example.py
+++ b/configuration.example.py
@@ -3,62 +3,8 @@
BOT_DESC = ''
BOT_AVAT = ''
-# Channels
+# Channel
AFK_CHANNELS = [345, 567, 678, 789]
-BUSY_CHANNEL = 345 # Busy
-# Module specifics
-WORDPRESS_UPDATE_INTERVAL_SECONDS = 15 * 60
-IDLE_MINUTES_BEFORE_MOVE = 20
-CHECK_AFK_INTERVAL_SECONDS = 10
-MEASUREMENT_INTERVAL_SECONDS = 5
-MEASUREMENT_EMPTY_INTERVAL_SECONDS = 5 * 60
-
-AFK_MOVED_MESSAGE = 'You were moved because of inactivity.'
-
-TRACK_TOGGLE_CMD = '!toggle'
-TRACKING_INFO_MSG = f'Your connection time is being tracked. To opt-out, enter [b]{TRACK_TOGGLE_CMD}[/b].'
-DO_NOT_TRACK_CONFIRMED_MSG = f'Your connection time is not being tracked anymore. ' \
- f'[b]{TRACK_TOGGLE_CMD}[/b] to undo.'
-
-CRACKERBARREL_REMINDER_3_DAYS = 'Crackerbarrel meeting in 3 days!'
-CRACKERBARREL_REMINDER_TODAY = 'Crackerbarrel meeting today 8pm!'
-
-BANNERS = {
- 'default': 'https://your-domain.com/files/banner-default.png',
- 'covid': 'https://your-domain.com/files/banner-corona.png',
- 'valentines': 'https://your-domain.com/files/banner-valentines.png',
- 'eastern': 'https://your-domain.com/files/banner-eastern.png',
- 'april fools': 'https://your-domain.com/files/banner-april-fools.png',
- 'mothers day': 'https://your-domain.com/files/banner-mothers-day.png',
- 'fathers day': 'https://your-domain.com/files/banner-fathers-day.png',
- 'halloween': 'https://your-domain.com/files/banner-halloween.png',
- 'christmas': 'https://your-domain.com/files/banner-christmas.png',
- 'new years': 'https://your-domain.com/files/banner-new-year.png',
-}
-
-
-# Games specifics
-ACCOUNTS_DB_NAME = 'accounts'
-ACCOUNT_START_BALANCE = 5000
-ACCOUNT_INFO_BALANCE = 'Your balance is {}.'
-
-GAME_INVALID_CMD = 'Please enter a valid command.'
-GAME_INVALID_AMOUNT = 'Please enter a valid amount.'
-GAME_INVALID_GAME = 'Please enter a valid game.'
-GAME_ABORT_BAD_BET = 'Please enter a valid bet!'
-GAME_ABORT_BROKE = 'Sorry, you don\'t have enough money!'
-GAME_ABORT_BAD_WAGER = 'Sorry, minimum wager is {}!'
-GAME_GREETINGS = 'Hello {}. Thank you for playing!' # player_name
-GAME_WON_MSG = 'You win [b][color={0}]{1}[/color][/b]!!' # color, win_amount
-GAME_LOST_MSG = 'Oh no! You lost [b][color=firebrick]{}[/color][/b]!' # wager
-
-# Slots
-SLOTS_MIN_WAGER = 50
-SLOTS_START_MSG = 'You started the slot machine! Good luck!'
-SLOTS_RESULT_MSG = 'Your reels show:'
-
-# Roulette
-ROULETTE_MIN_WAGER = 50
-ROULETTE_START_MSG = 'You bet [b]{0}[/b] on {1}! Let\'s spin the wheel!' # amount, number or name
-ROULETTE_RESULT_MSG = 'The ball lands on [b]{}[/b]!!' # winning_number
+# Client
+IDLE_MINUTES_BEFORE_AFK = 30
diff --git a/main.py b/main.py
index 1690ea2..df3b7fc 100644
--- a/main.py
+++ b/main.py
@@ -1,24 +1,28 @@
import threading
-from configuration import BOT_NAME, BOT_DESC, ACCOUNTS_DB_NAME, PROFILES_DB_NAME
+from configuration import BOT_NAME, BOT_DESC
from credentials import *
-from modules.reminder import crackerbarrel_reminder
-from modules.doodle import set_holiday_doodle
-from modules.move_afk import move_afk
+from modules.reminder import reminder
+from modules.doodle import doodle
+from modules.afk_mover import afk_mover
from modules.games import games, AccountDB
+from modules.games.configuration import ACCOUNTS_DB_NAME
+
from modules.time_tracker import time_tracker, wordpress, ProfilesDB, WordpressDB
+from modules.time_tracker.configuration import PROFILES_DB_NAME
-from TS3Bot import TS3Bot
+from ts3bot import TS3Bot
+from ts3query import TS3Query
def main():
- bot = TS3Bot(ip=SERVER_IP,
+ query = TS3Query(ip=SERVER_IP, port=TELNET_PORT)
+ bot = TS3Bot(query=query,
port=SERVER_PORT,
login=TELNET_LOGIN,
- password=TELNET_PW,
- telnet_port=TELNET_PORT)
+ password=TELNET_PW)
bot.set_bot_name(BOT_NAME)
bot.set_bot_description(BOT_DESC)
@@ -28,9 +32,9 @@ def main():
profile_db = ProfilesDB(PROFILES_DB_NAME)
wordpress_db = WordpressDB(MYSQL_HOST, MYSQL_DB_NAME, MYSQL_USER, MYSQL_PW, 'stats')
- crackerbarrel_reminder_thread = threading.Thread(target=crackerbarrel_reminder, kwargs={'bot': bot})
- holiday_doodle_thread = threading.Thread(target=set_holiday_doodle, kwargs={'bot': bot})
- move_afk_thread = threading.Thread(target=move_afk, kwargs={'bot': bot})
+ crackerbarrel_reminder_thread = threading.Thread(target=reminder.check_crackerbarrel_reminder, kwargs={'bot': bot})
+ holiday_doodle_thread = threading.Thread(target=doodle.set_holiday_doodle, kwargs={'bot': bot})
+ move_afk_thread = threading.Thread(target=afk_mover.move_afk, kwargs={'bot': bot})
games_thread = threading.Thread(target=games.start,
kwargs={
@@ -38,13 +42,13 @@ def main():
'database': accounts_db,
})
- time_measurement_thread = threading.Thread(target=time_tracker.start,
+ time_measurement_thread = threading.Thread(target=time_tracker.start_tracker,
kwargs={
'bot': bot,
'database': profile_db,
})
- wordpress_update_thread = threading.Thread(target=wordpress.update,
+ wordpress_update_thread = threading.Thread(target=wordpress.update_post,
kwargs={
'profile_db': profile_db,
'wordpress_db': wordpress_db,
diff --git a/Message.py b/message.py
similarity index 100%
rename from Message.py
rename to message.py
diff --git a/modules/move_afk.py b/modules/afk_mover/afk_mover.py
similarity index 74%
rename from modules/move_afk.py
rename to modules/afk_mover/afk_mover.py
index 871094e..13882a7 100644
--- a/modules/move_afk.py
+++ b/modules/afk_mover/afk_mover.py
@@ -1,6 +1,6 @@
import time
-from TS3Bot import TS3Bot
-from configuration import BUSY_CHANNEL, CHECK_AFK_INTERVAL_SECONDS, AFK_MOVED_MESSAGE
+from ts3bot import TS3Bot
+from .configuration import BUSY_CHANNEL, CHECK_AFK_INTERVAL_SECONDS, AFK_MOVED_MESSAGE
def move_afk(bot: TS3Bot):
diff --git a/modules/afk_mover/configuration.example.py b/modules/afk_mover/configuration.example.py
new file mode 100644
index 0000000..b2fa19a
--- /dev/null
+++ b/modules/afk_mover/configuration.example.py
@@ -0,0 +1,3 @@
+AFK_MOVED_MESSAGE = 'You were moved because of inactivity.'
+BUSY_CHANNEL = 345 # Busy
+CHECK_AFK_INTERVAL_SECONDS = 10
diff --git a/modules/doodle/configuration.example.py b/modules/doodle/configuration.example.py
new file mode 100644
index 0000000..5a292d3
--- /dev/null
+++ b/modules/doodle/configuration.example.py
@@ -0,0 +1,12 @@
+BANNERS = {
+ 'default': 'https://your-domain.com/files/banner-default.png',
+ 'covid': 'https://your-domain.com/files/banner-corona.png',
+ 'valentines': 'https://your-domain.com/files/banner-valentines.png',
+ 'eastern': 'https://your-domain.com/files/banner-eastern.png',
+ 'april fools': 'https://your-domain.com/files/banner-april-fools.png',
+ 'mothers day': 'https://your-domain.com/files/banner-mothers-day.png',
+ 'fathers day': 'https://your-domain.com/files/banner-fathers-day.png',
+ 'halloween': 'https://your-domain.com/files/banner-halloween.png',
+ 'christmas': 'https://your-domain.com/files/banner-christmas.png',
+ 'new years': 'https://your-domain.com/files/banner-new-year.png',
+}
diff --git a/modules/doodle.py b/modules/doodle/doodle.py
similarity index 93%
rename from modules/doodle.py
rename to modules/doodle/doodle.py
index fb4ae62..f1eff9c 100644
--- a/modules/doodle.py
+++ b/modules/doodle/doodle.py
@@ -1,7 +1,7 @@
import datetime
-from TS3Bot import TS3Bot
-from configuration import BANNERS
+from ts3bot import TS3Bot
+from .configuration import BANNERS
def set_holiday_doodle(bot: TS3Bot):
@@ -12,7 +12,7 @@ def set_holiday_doodle(bot: TS3Bot):
return bot.change_host_banner_image(BANNERS['april fools'])
elif today.month == 5 and 7 <= today.day <= 15 and today.weekday() == 6:
return bot.change_host_banner_image(BANNERS['mothers day'])
- elif today.month == 10 and 24 <= today.day <= 31:
+ elif today.month == 10 and 27 <= today.day <= 31:
return bot.change_host_banner_image(BANNERS['halloween'])
elif today.month == 12 and 1 <= today.day <= 26:
return bot.change_host_banner_image(BANNERS['christmas'])
diff --git a/modules/games/__init__.py b/modules/games/__init__.py
index 19c8c21..9af96d5 100644
--- a/modules/games/__init__.py
+++ b/modules/games/__init__.py
@@ -1 +1 @@
-from modules.games.AccountDB import AccountDB
+from modules.games.accounts_db import AccountDB
diff --git a/modules/games/AccountDB.py b/modules/games/accounts_db.py
similarity index 98%
rename from modules/games/AccountDB.py
rename to modules/games/accounts_db.py
index fd43649..9def161 100644
--- a/modules/games/AccountDB.py
+++ b/modules/games/accounts_db.py
@@ -1,6 +1,6 @@
from sqlite3 import OperationalError
-from SQLiteDB import SQLiteDB
-from configuration import ACCOUNT_START_BALANCE
+from sqlite_db import SQLiteDB
+from .configuration import ACCOUNT_START_BALANCE
class AccountDB(SQLiteDB):
diff --git a/modules/games/configuration.example.py b/modules/games/configuration.example.py
new file mode 100644
index 0000000..b7f3cf1
--- /dev/null
+++ b/modules/games/configuration.example.py
@@ -0,0 +1,23 @@
+ACCOUNTS_DB_NAME = 'accounts'
+ACCOUNT_START_BALANCE = 5000
+ACCOUNT_INFO_BALANCE = 'Your balance is {}.'
+
+GAME_INVALID_CMD = 'Please enter a valid command.'
+GAME_INVALID_AMOUNT = 'Please enter a valid amount.'
+GAME_INVALID_GAME = 'Please enter a valid game.'
+GAME_ABORT_BAD_BET = 'Please enter a valid bet!'
+GAME_ABORT_BROKE = 'Sorry, you don\'t have enough money!'
+GAME_ABORT_BAD_WAGER = 'Sorry, minimum wager is {}!'
+GAME_GREETINGS = 'Hello {}. Thank you for playing!' # player_name
+GAME_WON_MSG = 'You win [b][color={0}]{1}[/color][/b]!!' # color, win_amount
+GAME_LOST_MSG = 'Oh no! You lost [b][color=firebrick]{}[/color][/b]!' # wager
+
+# Slots
+SLOTS_MIN_WAGER = 50
+SLOTS_START_MSG = 'You started the slot machine! Good luck!'
+SLOTS_RESULT_MSG = 'Your reels show:'
+
+# Roulette
+ROULETTE_MIN_WAGER = 50
+ROULETTE_START_MSG = 'You bet [b]{0}[/b] on {1}! Let\'s spin the wheel!' # amount, number or name
+ROULETTE_RESULT_MSG = 'The ball lands on [b]{}[/b]!!' # winning_number
diff --git a/modules/games/games.py b/modules/games/games.py
index b954014..ea68d9e 100644
--- a/modules/games/games.py
+++ b/modules/games/games.py
@@ -1,15 +1,15 @@
import time
import threading
-from configuration import GAME_GREETINGS, GAME_INVALID_CMD, GAME_INVALID_AMOUNT, GAME_INVALID_GAME, \
+from .configuration import GAME_GREETINGS, GAME_INVALID_CMD, GAME_INVALID_AMOUNT, GAME_INVALID_GAME, \
GAME_ABORT_BROKE, GAME_ABORT_BAD_WAGER, GAME_ABORT_BAD_BET, ACCOUNT_INFO_BALANCE
-from modules.games.Slots import Slots
-from modules.games.Roulette import Roulette
-from modules.games.AccountDB import AccountDB
+from modules.games.slots import Slots
+from modules.games.roulette import Roulette
+from modules.games.accounts_db import AccountDB
-from Message import Message
-from TS3Bot import TS3Bot
+from message import Message
+from ts3bot import TS3Bot
GAMES = ['slots', 'roulette']
diff --git a/modules/games/Roulette.py b/modules/games/roulette.py
similarity index 95%
rename from modules/games/Roulette.py
rename to modules/games/roulette.py
index b465c5e..ecb9a56 100644
--- a/modules/games/Roulette.py
+++ b/modules/games/roulette.py
@@ -1,9 +1,9 @@
import random
import time
-from configuration import ROULETTE_MIN_WAGER, ROULETTE_START_MSG, ROULETTE_RESULT_MSG, GAME_LOST_MSG, GAME_WON_MSG
+from .configuration import ROULETTE_MIN_WAGER, ROULETTE_START_MSG, ROULETTE_RESULT_MSG, GAME_LOST_MSG, GAME_WON_MSG
from modules.games.formatting import get_color
-from TS3Bot import TS3Bot
+from ts3bot import TS3Bot
BETS = {
'low': {'name': 'Low',
diff --git a/modules/games/Slots.py b/modules/games/slots.py
similarity index 93%
rename from modules/games/Slots.py
rename to modules/games/slots.py
index 9313e11..cfece54 100644
--- a/modules/games/Slots.py
+++ b/modules/games/slots.py
@@ -1,9 +1,9 @@
import random
import time
-from configuration import GAME_WON_MSG, GAME_LOST_MSG, SLOTS_MIN_WAGER, SLOTS_START_MSG, SLOTS_RESULT_MSG
+from .configuration import GAME_WON_MSG, GAME_LOST_MSG, SLOTS_MIN_WAGER, SLOTS_START_MSG, SLOTS_RESULT_MSG
from modules.games.formatting import get_color
-from TS3Bot import TS3Bot
+from ts3bot import TS3Bot
REEL_OPTIONS = [option for option in enumerate([
diff --git a/modules/reminder/configuration.example.py b/modules/reminder/configuration.example.py
new file mode 100644
index 0000000..2ed037b
--- /dev/null
+++ b/modules/reminder/configuration.example.py
@@ -0,0 +1,2 @@
+REMINDER_3_DAYS_MSG = 'Crackerbarrel meeting in 3 days!'
+REMINDER_TODAY_MSG = 'Crackerbarrel meeting today 8pm!'
diff --git a/modules/reminder.py b/modules/reminder/reminder.py
similarity index 72%
rename from modules/reminder.py
rename to modules/reminder/reminder.py
index 24af234..9db767c 100644
--- a/modules/reminder.py
+++ b/modules/reminder/reminder.py
@@ -1,8 +1,8 @@
import calendar
import datetime
-from TS3Bot import TS3Bot
-from configuration import CRACKERBARREL_REMINDER_3_DAYS, CRACKERBARREL_REMINDER_TODAY
+from ts3bot import TS3Bot
+from .configuration import REMINDER_3_DAYS_MSG, REMINDER_TODAY_MSG
days = {
'Monday': 0,
@@ -15,17 +15,17 @@
}
-def crackerbarrel_reminder(bot: TS3Bot):
+def check_crackerbarrel_reminder(bot: TS3Bot):
today = datetime.datetime.today()
wednesday = days['Wednesday']
last_wednesday = last_weekday_of_month(wednesday, today.year, today.month)
if today.day == last_wednesday:
bot.set_host_message_mode(2)
- return bot.set_new_host_message(CRACKERBARREL_REMINDER_TODAY)
+ return bot.set_new_host_message(REMINDER_TODAY_MSG)
elif today.day == last_wednesday - 3:
bot.set_host_message_mode(2)
- return bot.set_new_host_message(CRACKERBARREL_REMINDER_3_DAYS)
+ return bot.set_new_host_message(REMINDER_3_DAYS_MSG)
elif today.day == last_wednesday + 1:
return bot.reset_host_message()
diff --git a/modules/time_tracker/__init__.py b/modules/time_tracker/__init__.py
index b4785fe..9162ab7 100644
--- a/modules/time_tracker/__init__.py
+++ b/modules/time_tracker/__init__.py
@@ -1,2 +1,2 @@
-from modules.time_tracker.ProfilesDB import ProfilesDB
-from modules.time_tracker.WordpressDB import WordpressDB
+from modules.time_tracker.profiles_db import ProfilesDB
+from modules.time_tracker.wordpress_db import WordpressDB
diff --git a/modules/time_tracker/configuration.example.py b/modules/time_tracker/configuration.example.py
new file mode 100644
index 0000000..7eeb3d8
--- /dev/null
+++ b/modules/time_tracker/configuration.example.py
@@ -0,0 +1,11 @@
+# Tracking
+PROFILES_DB_NAME = 'profiles'
+MEASUREMENT_INTERVAL_SECONDS = 5
+MEASUREMENT_EMPTY_INTERVAL_SECONDS = 5 * 60
+TRACK_TOGGLE_CMD = '!toggle'
+TRACKING_INFO_MSG = f'Your connection time is being tracked. To opt-out, enter [b]{TRACK_TOGGLE_CMD}[/b].'
+DO_NOT_TRACK_CONFIRMED_MSG = f'Your connection time is not being tracked anymore. ' \
+ f'[b]{TRACK_TOGGLE_CMD}[/b] to undo.'
+
+# WordPress
+WORDPRESS_UPDATE_INTERVAL_SECONDS = 15 * 60
diff --git a/modules/time_tracker/HTMLTable.py b/modules/time_tracker/html_table.py
similarity index 100%
rename from modules/time_tracker/HTMLTable.py
rename to modules/time_tracker/html_table.py
diff --git a/modules/time_tracker/ProfilesDB.py b/modules/time_tracker/profiles_db.py
similarity index 98%
rename from modules/time_tracker/ProfilesDB.py
rename to modules/time_tracker/profiles_db.py
index 501b3bf..ee76a9c 100644
--- a/modules/time_tracker/ProfilesDB.py
+++ b/modules/time_tracker/profiles_db.py
@@ -1,8 +1,8 @@
from sqlite3 import OperationalError
import time
-from Client import Client
-from SQLiteDB import SQLiteDB
+from client import Client
+from sqlite_db import SQLiteDB
class ProfilesDB(SQLiteDB):
diff --git a/modules/time_tracker/time_tracker.py b/modules/time_tracker/time_tracker.py
index c323568..078cac9 100644
--- a/modules/time_tracker/time_tracker.py
+++ b/modules/time_tracker/time_tracker.py
@@ -1,13 +1,13 @@
import time
-from configuration import TRACK_TOGGLE_CMD, TRACKING_INFO_MSG, DO_NOT_TRACK_CONFIRMED_MSG, \
+from .configuration import TRACK_TOGGLE_CMD, TRACKING_INFO_MSG, DO_NOT_TRACK_CONFIRMED_MSG, \
MEASUREMENT_EMPTY_INTERVAL_SECONDS, MEASUREMENT_INTERVAL_SECONDS
-from modules.time_tracker.ProfilesDB import ProfilesDB
-from TS3Bot import TS3Bot
+from modules.time_tracker.profiles_db import ProfilesDB
+from ts3bot import TS3Bot
-def start(bot: TS3Bot, database: ProfilesDB):
+def start_tracker(bot: TS3Bot, database: ProfilesDB):
messaged_clients = list()
first_timecheck = round(time.time(), 3)
while 1:
@@ -28,10 +28,10 @@ def start(bot: TS3Bot, database: ProfilesDB):
continue
do_not_track = database.get_do_not_track(client.uid)
- __inform_client(bot, client.id, do_not_track)
+ _inform_client(bot, client.id, do_not_track)
messaged_clients.append(client.b64_uid)
- __check_toggle_messages(bot, database)
+ _check_toggle_messages(bot, database)
time.sleep(MEASUREMENT_INTERVAL_SECONDS)
@@ -63,7 +63,7 @@ def start(bot: TS3Bot, database: ProfilesDB):
database.update_profile_afk(client, new_afk)
-def __check_toggle_messages(bot, database):
+def _check_toggle_messages(bot, database):
for message in bot.unused_messages:
if message.content != TRACK_TOGGLE_CMD:
continue
@@ -71,10 +71,10 @@ def __check_toggle_messages(bot, database):
message.mark_as_used()
do_not_track = database.toggle_do_not_track(message.invoker_uid)
- __inform_client(bot, message.invoker_id, do_not_track)
+ _inform_client(bot, message.invoker_id, do_not_track)
-def __inform_client(bot, client_id: int, do_not_track: bool):
+def _inform_client(bot, client_id: int, do_not_track: bool):
if do_not_track:
msg = DO_NOT_TRACK_CONFIRMED_MSG
else:
diff --git a/modules/time_tracker/wordpress.py b/modules/time_tracker/wordpress.py
index 54455b9..a5f6592 100644
--- a/modules/time_tracker/wordpress.py
+++ b/modules/time_tracker/wordpress.py
@@ -1,13 +1,13 @@
import time
-from configuration import WORDPRESS_UPDATE_INTERVAL_SECONDS
+from .configuration import WORDPRESS_UPDATE_INTERVAL_SECONDS
-from modules.time_tracker.HTMLTable import HTMLTable
-from modules.time_tracker.ProfilesDB import ProfilesDB
-from modules.time_tracker.WordpressDB import WordpressDB
+from modules.time_tracker.html_table import HTMLTable
+from modules.time_tracker.profiles_db import ProfilesDB
+from modules.time_tracker.wordpress_db import WordpressDB
-def update(profile_db: ProfilesDB, wordpress_db: WordpressDB):
+def update_post(profile_db: ProfilesDB, wordpress_db: WordpressDB):
while 1:
table = HTMLTable(columns=5)
table.add_header('Rang', 'Name', 'Aktiv', 'Abwesend', 'Gesamt')
@@ -25,9 +25,9 @@ def update(profile_db: ProfilesDB, wordpress_db: WordpressDB):
table.add_row(
rank,
profile['nickname'],
- __format_time_from_seconds(profile['connected_total'] - profile['connected_afk']),
- __format_time_from_seconds(profile['connected_afk']),
- __format_time_from_seconds(profile['connected_total'])
+ _format_time_from_seconds(profile['connected_total'] - profile['connected_afk']),
+ _format_time_from_seconds(profile['connected_afk']),
+ _format_time_from_seconds(profile['connected_total'])
)
table_html = table.generate()
@@ -36,7 +36,7 @@ def update(profile_db: ProfilesDB, wordpress_db: WordpressDB):
time.sleep(WORDPRESS_UPDATE_INTERVAL_SECONDS)
-def __format_time_from_seconds(seconds):
+def _format_time_from_seconds(seconds):
minutes, seconds = divmod(int(seconds), 60)
hours, minutes = divmod(minutes, 60)
return f'{hours}:{minutes:02}:{seconds:02}'
diff --git a/modules/time_tracker/WordpressDB.py b/modules/time_tracker/wordpress_db.py
similarity index 100%
rename from modules/time_tracker/WordpressDB.py
rename to modules/time_tracker/wordpress_db.py
diff --git a/SQLiteDB.py b/sqlite_db.py
similarity index 100%
rename from SQLiteDB.py
rename to sqlite_db.py
diff --git a/TS3Bot.py b/ts3bot.py
similarity index 96%
rename from TS3Bot.py
rename to ts3bot.py
index 3600ed8..50a938d 100644
--- a/TS3Bot.py
+++ b/ts3bot.py
@@ -1,7 +1,7 @@
-from Client import Client
-from Channel import Channel
-from Message import Message
-from TS3Query import TS3Query
+from client import Client
+from channel import Channel
+from message import Message
+from ts3query import TS3Query
def dict_to_parameters(parameters: dict):
@@ -16,16 +16,15 @@ class TS3Bot:
"""
An interface to send commands to the server.
"""
- def __init__(self, ip, port, login, password, telnet_port):
+ def __init__(self, query: TS3Query, port: int, login: str, password: str):
"""
A bot connected to a TeamSpeak 3 Server via Telnet.
- :param ip: TS3 server IP address.
+ :param query: A connected TS3Query.
:param port: TS3 server port.
:param login: TS3 query login name.
:param password: TS3 query login password.
- :param telnet_port: TS3 telnet port.
"""
- self.connection = TS3Query(ip, telnet_port)
+ self.connection = query
self.connection.login(login, password)
self.connection.use(port=port)
self.client_id = self.whoami()['client_id']
diff --git a/TS3Query.py b/ts3query.py
similarity index 100%
rename from TS3Query.py
rename to ts3query.py