Skip to content

Commit d6f5cdd

Browse files
committed
2 parents 7db45cc + 2198c38 commit d6f5cdd

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

bot.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from db.tortoise_config import DBConfig
1313
from db.redis import RedisDB
1414
from server import GrahamServer
15+
from tortoise import Tortoise
1516
from util.discord.channel import ChannelUtil
1617
from util.env import Env
1718
from util.logger import setup_logger
@@ -103,7 +104,8 @@ async def on_message(message: discord.Message):
103104
tasks = [
104105
client.logout(),
105106
RPCClient.close(),
106-
RedisDB.close()
107+
RedisDB.close(),
108+
Tortoise.close_connections()
107109
]
108110
loop.run_until_complete(asyncio.wait(tasks))
109111
loop.close()

cogs/favorites.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
triggers = ["banfavorites" if Env.banano() else "ntipfavorites"],
4040
overview = "Tip all the favorites",
4141
details = f"Split a tip among all of the users in your favorites list - similar to a tipsplit. (**minimum tip is {Constants.TIP_MINIMUM} {Constants.TIP_UNIT}**)" +
42-
"\nExample: `{config.Config.instance().command_prefix}{'banfavorites' if Env.banano() else 'ntipfavorites'} <amount>`"
42+
f"\nExample: `{config.Config.instance().command_prefix}{'banfavorites' if Env.banano() else 'ntipfavorites'} <amount>`"
4343
)
4444

4545
class FavoriteCog(commands.Cog):
@@ -317,4 +317,4 @@ async def tipfavorites_cmd(self, ctx: Context):
317317
# Update stats
318318
stats: Stats = await user.get_stats(server_id=msg.guild.id)
319319
if msg.channel.id not in config.Config.instance().get_no_stats_channels():
320-
await stats.update_tip_stats(amount_needed)
320+
await stats.update_tip_stats(amount_needed)

config.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def instance(cls) -> 'Config':
2929
parser.add_argument('-p', '--prefix', type=str, help='Command prefix for bot commands', default='!')
3030
parser.add_argument('-l', '--log-file', type=str, help='Log file location', default='/tmp/graham_bot.log')
3131
parser.add_argument('-s', '--status', type=str, help="The bot's 'playing status'", default=None, required=False)
32-
parser.add_argument('-u', '--node-url', type=str, help='URL of the node', default='[::1]')
33-
parser.add_argument('-np', '--node-port', type=int, help='Port of the node', default=7072 if Env.banano() else 7076)
32+
parser.add_argument('-u', '--node-url', type=str, help='URL of the node, e.g.: http://[::1]:7072', default='http://[::1]:7072' if Env.banano() else 'http://[::1]:7076')
3433
parser.add_argument('--debug', action='store_true', help='Runs in debug mode if specified', default=False)
3534
options, unknown = parser.parse_known_args()
3635

@@ -53,7 +52,6 @@ def instance(cls) -> 'Config':
5352
exit(1)
5453

5554
cls.node_url = options.node_url
56-
cls.node_port = options.node_port
5755
return cls._instance
5856

5957
def has_yaml(self) -> bool:

db/redis.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def instance(cls) -> 'RedisDB':
1919
@classmethod
2020
async def close(cls):
2121
if hasattr(cls, 'redis') and cls.redis is not None:
22+
cls.redis.close()
2223
await cls.redis.wait_closed()
2324
if cls._instance is not None:
2425
cls._instance = None
@@ -76,4 +77,4 @@ async def is_paused(self) -> bool:
7677
"""Return True if the bot is paused or not"""
7778
key = f"{Env.currency_name().lower()}:botpaused"
7879
redis = await self.get_redis()
79-
return (await redis.get(key)) is not None
80+
return (await redis.get(key)) is not None

rpc/client.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ def __init__(self):
1414
def instance(cls) -> 'RPCClient':
1515
if cls._instance is None:
1616
cls._instance = cls.__new__(cls)
17-
cls.node_url = Config.instance().node_url
18-
cls.node_port = Config.instance().node_port
1917
cls.wallet_id = Config.instance().wallet
20-
cls.ipv6 = '::' in cls.node_url
21-
cls.connector = aiohttp.TCPConnector(family=socket.AF_INET6 if cls.ipv6 else socket.AF_INET,resolver=aiohttp.AsyncResolver())
18+
cls.node_url = Config.instance().node_url
19+
cls.connector = aiohttp.TCPConnector(family=0 ,resolver=aiohttp.AsyncResolver())
2220
cls.session = aiohttp.ClientSession(connector=cls.connector, json_serialize=json.dumps)
2321
return cls._instance
2422

@@ -30,7 +28,7 @@ async def close(cls):
3028
cls._instance = None
3129

3230
async def make_request(self, req_json: dict):
33-
async with self.session.post("http://{0}:{1}".format(self.node_url, self.node_port),json=req_json, timeout=300) as resp:
31+
async with self.session.post(self.node_url ,json=req_json, timeout=300) as resp:
3432
return await resp.json()
3533

3634
async def account_create(self) -> str:

0 commit comments

Comments
 (0)