Remove post-reaction verification refetch
Was doing an extra fetch_message per reaction to confirm the reaction stuck. Turned out to be unrelated to the earlier missing-reactions bug (that was the scan-state resume issue), so drop it to save the API calls.
This commit is contained in:
@@ -13,7 +13,6 @@ class Config:
|
|||||||
db_path: str
|
db_path: str
|
||||||
log_level: str
|
log_level: str
|
||||||
manual_guild_ids: List[int] = field(default_factory=list)
|
manual_guild_ids: List[int] = field(default_factory=list)
|
||||||
verify_reactions: bool = True
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(path: str = "config.json") -> Config:
|
def load_config(path: str = "config.json") -> Config:
|
||||||
@@ -38,5 +37,4 @@ def load_config(path: str = "config.json") -> Config:
|
|||||||
db_path=data.get("db_path", "reactions.sqlite3"),
|
db_path=data.get("db_path", "reactions.sqlite3"),
|
||||||
log_level=data.get("log_level", "INFO"),
|
log_level=data.get("log_level", "INFO"),
|
||||||
manual_guild_ids=[int(g) for g in data.get("manual_guild_ids", [])],
|
manual_guild_ids=[int(g) for g in data.get("manual_guild_ids", [])],
|
||||||
verify_reactions=bool(data.get("verify_reactions", True)),
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ async def react_to_message(
|
|||||||
emoji: str,
|
emoji: str,
|
||||||
source: str,
|
source: str,
|
||||||
display: Optional[StatsDisplay] = None,
|
display: Optional[StatsDisplay] = None,
|
||||||
verify: bool = True,
|
|
||||||
) -> bool:
|
) -> bool:
|
||||||
if message.author.id != friend_id:
|
if message.author.id != friend_id:
|
||||||
return False
|
return False
|
||||||
@@ -47,20 +46,6 @@ async def react_to_message(
|
|||||||
log.exception("Failed to react to message %s in channel %s", message.id, message.channel.id)
|
log.exception("Failed to react to message %s in channel %s", message.id, message.channel.id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if verify:
|
|
||||||
try:
|
|
||||||
refetched = await message.channel.fetch_message(message.id)
|
|
||||||
confirmed = any(r.me and str(r.emoji) == emoji for r in refetched.reactions)
|
|
||||||
except discord.HTTPException:
|
|
||||||
confirmed = None # couldn't verify either way; don't block on it
|
|
||||||
|
|
||||||
if confirmed is False:
|
|
||||||
log.warning(
|
|
||||||
"Reaction API call succeeded but is NOT visible on refetch! "
|
|
||||||
"message=%s channel=%s target=%s (%s) url=%s",
|
|
||||||
message.id, message.channel.id, target.name, target.target_type, message.jump_url,
|
|
||||||
)
|
|
||||||
|
|
||||||
inserted = await asyncio.to_thread(
|
inserted = await asyncio.to_thread(
|
||||||
storage.record_reaction,
|
storage.record_reaction,
|
||||||
message.id,
|
message.id,
|
||||||
|
|||||||
@@ -5,6 +5,5 @@
|
|||||||
"days_back": 10,
|
"days_back": 10,
|
||||||
"db_path": "reactions.sqlite3",
|
"db_path": "reactions.sqlite3",
|
||||||
"log_level": "INFO",
|
"log_level": "INFO",
|
||||||
"manual_guild_ids": [],
|
"manual_guild_ids": []
|
||||||
"verify_reactions": true
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -72,7 +72,7 @@ class ReactorClient(discord.Client):
|
|||||||
async def react_fn(message: discord.Message, target: Target) -> bool:
|
async def react_fn(message: discord.Message, target: Target) -> bool:
|
||||||
return await react_to_message(
|
return await react_to_message(
|
||||||
self.storage, message, target, self.cfg.friend_id, self.cfg.emoji,
|
self.storage, message, target, self.cfg.friend_id, self.cfg.emoji,
|
||||||
source="backlog", display=self.display, verify=self.cfg.verify_reactions,
|
source="backlog", display=self.display,
|
||||||
)
|
)
|
||||||
|
|
||||||
for target in targets:
|
for target in targets:
|
||||||
@@ -100,7 +100,7 @@ class ReactorClient(discord.Client):
|
|||||||
return
|
return
|
||||||
await react_to_message(
|
await react_to_message(
|
||||||
self.storage, message, target, self.cfg.friend_id, self.cfg.emoji,
|
self.storage, message, target, self.cfg.friend_id, self.cfg.emoji,
|
||||||
source="live", display=self.display, verify=self.cfg.verify_reactions,
|
source="live", display=self.display,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user