fixed a bug in the discord account getter

fixed !lastseen on discord, aswell as multi-page responses
This commit is contained in:
2022-05-14 17:39:18 +02:00
parent 72ccd475af
commit e942ac43fa
7 changed files with 17 additions and 12 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ class IgnCore:
self.last_timer_event = 0 self.last_timer_event = 0
self.start_time = int(time.time()) self.start_time = int(time.time())
self.major_version = "IGNCore v2.9" self.major_version = "IGNCore v2.9"
self.minor_version = "3" self.minor_version = "4"
self.incoming_queue = FifoQueue() self.incoming_queue = FifoQueue()
self.mass_message_queue = None self.mass_message_queue = None
self.conns = DictObject() self.conns = DictObject()
@@ -92,10 +92,10 @@ class DiscordCommandHandler(BaseModule):
body = self.discord.text.split_by_separators(embeds.description, 4000, 10) body = self.discord.text.split_by_separators(embeds.description, 4000, 10)
tmp1 = embeds tmp1 = embeds
embeds = [] embeds = []
for x in enumerate(body): for x, e in enumerate(body):
tmp = tmp1.copy() tmp = tmp1.copy()
tmp.description = body[x] tmp.description = e
tmp.title += f"*Page ({x}/{len(body)}*" tmp.title += f"*Page ({x}/{len(body)})*"
embeds.append(tmp) embeds.append(tmp)
else: else:
embeds = [embeds] embeds = [embeds]
+2 -1
View File
@@ -186,8 +186,9 @@ class DiscordController:
elif type(msg) == ChatBlob: elif type(msg) == ChatBlob:
if msg.embed: if msg.embed:
msg: ChatBlob msg: ChatBlob
des = self.cmd.parseDiscord(msg.msg, blob=True)
blob = Embed(title=self.cmd.parseDiscord(f"{msg.page_prefix} {msg.title} {msg.page_postfix}"), blob = Embed(title=self.cmd.parseDiscord(f"{msg.page_prefix} {msg.title} {msg.page_postfix}"),
color=0x00FF00, description=self.cmd.parseDiscord(msg.msg, blob=True).replace("\n> ", '\n')) color=0x00FF00, description=(des or "").replace("\n> ", '\n'))
asyncio.run_coroutine_threadsafe(ch.send("", delete_after=del_after, embed=blob), self.loop) asyncio.run_coroutine_threadsafe(ch.send("", delete_after=del_after, embed=blob), self.loop)
return return
rsp = self.cmd.parseDiscord(ctx.formatted_message.page_prefix) + "\n" rsp = self.cmd.parseDiscord(ctx.formatted_message.page_prefix) + "\n"
+2 -3
View File
@@ -18,8 +18,7 @@ class DiscordData:
return self.db.exec("UPDATE account SET discord_handle = ? WHERE discord_id = ?", [handle, discord_id]) return self.db.exec("UPDATE account SET discord_handle = ? WHERE discord_id = ?", [handle, discord_id])
def get_discord_invite(self, invite): def get_discord_invite(self, invite):
return self.db.query_single("SELECT * FROM account WHERE discord_invite = ?", [invite]) return self.db.query_single("SELECT * FROM account WHERE discord_invite = ? and a.main=a.char_id", [invite])
def get_account_discord_id(self, discord_id): def get_account_discord_id(self, discord_id):
return self.db.query_single( return self.db.query_single("SELECT * FROM account a left join player p on a.char_id=p.char_id WHERE a.discord_id = ? and a.main=a.char_id", [discord_id])
"SELECT * FROM account a left join player p on a.char_id=p.char_id WHERE discord_id = ?", [discord_id])
-1
View File
@@ -6,7 +6,6 @@ and is being maintained by a group <highlight>Volunteers</highlight>.
At this point, we'd like to send a special "thank you" to the following people, which in one way or another, contributed to IGNCore/IGNCom: At this point, we'd like to send a special "thank you" to the following people, which in one way or another, contributed to IGNCore/IGNCom:
» <highlight>Zetabyte & its Network</highlight>, for many feature ideas, » <highlight>Zetabyte & its Network</highlight>, for many feature ideas,
and the heavy assistance with knowledge. and the heavy assistance with knowledge.
» <highlight>Chrisax</highlight> for hosting the !history mirror.
» Everyone who participated in test runs, » Everyone who participated in test runs,
» sent us ideas for bot improvements, » sent us ideas for bot improvements,
» helped us by sending bug reports our way, » helped us by sending bug reports our way,
+2 -2
View File
@@ -1,6 +1,7 @@
import time import time
from core.buddy_service import BuddyService from core.buddy_service import BuddyService
from core.chat_blob import ChatBlob
from core.command_param_types import Character, Int from core.command_param_types import Character, Int
from core.decorators import event, instance, command from core.decorators import event, instance, command
from core.logger import Logger from core.logger import Logger
@@ -57,8 +58,7 @@ class NotifyController:
for log in logs: for log in logs:
blob += f"<grey>[{self.util.format_datetime(log.time)}]</grey> <highlight>{log.name}</highlight> -> " \ blob += f"<grey>[{self.util.format_datetime(log.time)}]</grey> <highlight>{log.name}</highlight> -> " \
f"{'<green>logged on</green>' if log.status == 1 else '<red>logged off</red>'}.\n" f"{'<green>logged on</green>' if log.status == 1 else '<red>logged off</red>'}.\n"
return f"<highlight>{char.name}</highlight> was last seen at " \ return ChatBlob("More", blob, prefix=f"<highlight>{char.name}</highlight> was last seen at {self.util.format_date(logs[0].time)}. [", suffix="]")
f"{self.util.format_date(logs[0].time)}. {self.text.format_page('More', blob)}"
def get_log(self, char_list, length=16): def get_log(self, char_list, length=16):
query = "SELECT n.*, p.name as name FROM notify_log n LEFT JOIN player p on n.char_id = p.char_id " query = "SELECT n.*, p.name as name FROM notify_log n LEFT JOIN player p on n.char_id = p.char_id "
+7 -1
View File
@@ -5,7 +5,7 @@ from datetime import datetime
import pytz import pytz
from core.chat_blob import ChatBlob from core.chat_blob import ChatBlob
from core.command_param_types import Any, Const from core.command_param_types import Any, Const, Int
from core.decorators import instance, command from core.decorators import instance, command
@@ -50,6 +50,12 @@ class TimeController:
return f"Currently its {now.hour:02}:{now.minute:02}:{now.second:02} " \ return f"Currently its {now.hour:02}:{now.minute:02}:{now.second:02} " \
f"{calendar.month_name[now.month]} {day}, {now.year + 27474} Rubi-Ka Universal Time." f"{calendar.month_name[now.month]} {day}, {now.year + 27474} Rubi-Ka Universal Time."
@command(command="time", params=[Int("timestamp")], access_level="member",
description="Show UTC time of the provided timestamp")
def timestamp_cmd(self, _, t: int):
d = datetime.fromtimestamp(t, pytz.utc)
return f"Your provided timestamp resolves to: <highlight>{d.strftime(self.time_format)}</highlight>"
@command(command="time", params=[Any("timezone")], access_level="member", @command(command="time", params=[Any("timezone")], access_level="member",
description="Show time for the specified timezone") description="Show time for the specified timezone")
def time_zone_cmd(self, _, timezone_str): def time_zone_cmd(self, _, timezone_str):