diff --git a/skynet/cli.py b/skynet/cli.py
index 385b056..34c4562 100755
--- a/skynet/cli.py
+++ b/skynet/cli.py
@@ -439,7 +439,7 @@ def telegram(
@run.command()
@click.option('--loglevel', '-l', default='INFO', help='logging level')
@click.option(
- '--account', '-a', default='discord')
+ '--account', '-a', default=None)
@click.option(
'--permission', '-p', default='active')
@click.option(
@@ -485,7 +485,7 @@ def discord(
permission,
node_url,
hyperion_url,
- db_host, db_user, db_pass,
+ # db_host, db_user, db_pass,
remote_ipfs_node=ipfs_url,
key=key
)
diff --git a/skynet/frontend/discord/__init__.py b/skynet/frontend/discord/__init__.py
index 42afd17..1c0df56 100644
--- a/skynet/frontend/discord/__init__.py
+++ b/skynet/frontend/discord/__init__.py
@@ -16,7 +16,8 @@ from leap.sugar import Name, asset_from_str, collect_stdout
from leap.hyperion import HyperionAPI
# from telebot.types import InputMediaPhoto
-# import discord
+import discord
+import io
from skynet.db import open_new_database, open_database_connection
from skynet.ipfs import get_ipfs_file
@@ -34,24 +35,24 @@ class SkynetDiscordFrontend:
def __init__(
self,
- token: str,
+ # token: str,
account: str,
permission: str,
node_url: str,
hyperion_url: str,
- db_host: str,
- db_user: str,
+ # db_host: str,
+ # db_user: str,
# db_pass: str,
remote_ipfs_node: str,
key: str
):
- self.token = token
+ # self.token = token
self.account = account
self.permission = permission
self.node_url = node_url
self.hyperion_url = hyperion_url
- self.db_host = db_host
- self.db_user = db_user
+ # self.db_host = db_host
+ # self.db_user = db_user
# self.db_pass = db_pass
self.remote_ipfs_node = remote_ipfs_node
self.key = key
@@ -115,6 +116,7 @@ class SkynetDiscordFrontend:
status_msg,
method: str,
params: dict,
+ ctx: discord.TextChannel,
file_id: str | None = None,
binary_data: str = ''
):
@@ -134,13 +136,17 @@ class SkynetDiscordFrontend:
})
request_time = datetime.now().isoformat()
- # import pdb; pdb.set_trace()
+ # maybe get rid of this
# await self.update_status_message(
# status_msg,
# f'processing a \'{method}\' request by {tg_user_pretty(user)}\n'
# f'[{timestamp_pretty()}] broadcasting transaction to chain...',
# parse_mode='HTML'
# )
+ message = await ctx.send(
+ f'processing a \'{method}\' request by {user}\n \
+ [{timestamp_pretty()}] *broadcasting transaction to chain...*'
+ )
reward = '20.0000 GPU'
res = await self.cleos.a_push_action(
@@ -178,6 +184,12 @@ class SkynetDiscordFrontend:
# parse_mode='HTML'
# )
+ await message.edit(
+ f'**broadcasted!**\n \
+ **{enqueue_tx_link}**\n \
+ [{timestamp_pretty()}] *workers are processing request...*'
+ )
+
out = collect_stdout(res)
request_id, nonce = out.split(':')
@@ -238,13 +250,18 @@ class SkynetDiscordFrontend:
# f'[{timestamp_pretty()}] trying to download image...\n',
# parse_mode='HTML'
# )
+ await message.edit(
+ f'**request processed!**\n \
+ **{tx_link}**\n \
+ [{timestamp_pretty()}] *trying to download image...*\n'
+ )
# attempt to get the image and send it
ipfs_link = f'https://ipfs.{DEFAULT_DOMAIN}/ipfs/{ipfs_hash}/image.png'
resp = await get_ipfs_file(ipfs_link)
- caption = generate_reply_caption(
- user, params, tx_hash, worker, reward)
+ # caption = generate_reply_caption(
+ # user, params, tx_hash, worker, reward)
if not resp or resp.status_code != 200:
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
@@ -257,9 +274,11 @@ class SkynetDiscordFrontend:
#
else:
logging.info(f'success! sending generated image')
+ image = io.BytesIO(resp.raw)
# await self.bot.delete_message(
# chat_id=status_msg.chat.id, message_id=status_msg.id)
- # if file_id: # img2img
+ if file_id: # img2img
+ pass
# await self.bot.send_media_group(
# status_msg.chat.id,
# media=[
@@ -272,11 +291,14 @@ class SkynetDiscordFrontend:
# ],
# )
#
- # else: # txt2img
- # await self.bot.send_photo(
- # status_msg.chat.id,
- # caption=caption,
- # photo=resp.raw,
- # reply_markup=build_redo_menu(),
- # parse_mode='HTML'
- # )
+ else: # txt2img
+ # await self.bot.send_photo(
+ # status_msg.chat.id,
+ # caption=caption,
+ # photo=resp.raw,
+ # reply_markup=build_redo_menu(),
+ # parse_mode='HTML'
+ # )
+ await ctx.send(
+ file=discord.File(image, 'image.png')
+ )
diff --git a/skynet/frontend/discord/bot.py b/skynet/frontend/discord/bot.py
index 340b89d..d8ecb3b 100644
--- a/skynet/frontend/discord/bot.py
+++ b/skynet/frontend/discord/bot.py
@@ -29,7 +29,7 @@ class DiscordBot(commands.Bot):
message_content=True,
voice_states=True
)
- super().__init__(command_prefix='\\', intents=intents, *args, **kwargs)
+ super().__init__(command_prefix='/', intents=intents, *args, **kwargs)
# async def setup_hook(self):
# db.poll_db.start()
diff --git a/skynet/frontend/discord/handlers.py b/skynet/frontend/discord/handlers.py
index c408840..cbde27e 100644
--- a/skynet/frontend/discord/handlers.py
+++ b/skynet/frontend/discord/handlers.py
@@ -35,16 +35,21 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'):
@bot.command(name='txt2img', help='Responds with an image')
async def send_txt2img(ctx, *, arg):
- user = 'tests'
+ user = 'testworker3'
status_msg = 'status'
params = {
'prompt': arg,
'seed': None,
'step': 35,
- 'guidance': 1,
+ 'guidance': 7.5,
+ 'strength': 0.5,
+ 'width': 512,
+ 'height': 512,
+ 'upscaler': None,
+ 'model': 'prompthero/openjourney',
}
- # import pdb; pdb.set_trace()
- ec = await work_request(user, status_msg, 'txt2img', params)
+
+ ec = await work_request(user, status_msg, 'txt2img', params, ctx)
print(ec)
# if ec == 0: