Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-Klatzer committed Sep 1, 2021
1 parent ada5e47 commit 2405d5a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
12 changes: 0 additions & 12 deletions doc-examples/hivenclient/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ async def on_user_update(self, old, new):
async def on_message_create(self, msg):
print(f"{msg.author.name} wrote in {msg.room.name}: {msg.content}")

async def on_house_member_join(self, member, house):
print(f"{member.name} joined {house.name}")

async def on_member_update(self, old, new, house):
print(f"Member {old.name} of house {house.name} updated their account")

async def on_message_update(self, msg):
print(f"{msg.author.name} updated their message to: {msg.content}")

async def on_room_create(self, room):
print(f"{repr(room)} was created")


if __name__ == '__main__':
client = Bot()
Expand Down
16 changes: 15 additions & 1 deletion doc-examples/hivenclient/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import openhivenpy as hiven

logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("openhivenpy")
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='openhiven.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)

client = hiven.UserClient()

Expand All @@ -11,5 +16,14 @@
async def on_ready():
print("Bot is ready")

@client.event()
async def on_user_update(self, old, new):
print(f"{old.name} updated their account")


@client.event()
async def on_message_create(self, msg):
print(f"{msg.author.name} wrote in {msg.room.name}: {msg.content}")


client.run("Insert token")
5 changes: 3 additions & 2 deletions doc-examples/openhiven_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

import openhivenpy
from openhivenpy import Message

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("openhivenpy")
Expand All @@ -19,8 +20,8 @@ async def on_ready():


@client.event()
async def on_message_create():
print(f"Message was created")
async def on_message_create(msg: Message):
print(f"Message was created - {msg.content}")


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion doc-examples/selfbot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

import openhivenpy
from openhivenpy import Message

logger = logging.getLogger("openhivenpy")
logger.setLevel(logging.DEBUG)
Expand All @@ -17,7 +18,7 @@ async def on_ready():


@bot.event
async def on_message_create(message):
async def on_message_create(message: Message):
# Until theres a command handler, might as well go old-school discord.py
if message.content == ".ping":
await message.room.send(":table_tennis_paddle_and_ball:!")
Expand Down

0 comments on commit 2405d5a

Please sign in to comment.