Skip to content

Commit

Permalink
Merge pull request #17 from The-CJ/typing-ide
Browse files Browse the repository at this point in the history
Typing ide
  • Loading branch information
The-CJ committed Jan 14, 2021
2 parents a09993b + 1902bfa commit 5f4b1c7
Show file tree
Hide file tree
Showing 16 changed files with 242 additions and 256 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__pycache__
__pycache__
venv/
.idea/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2020 The_CJ
Copyright (c) 2018-2021 The_CJ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ but usable to any purpose
## Install

There are many ways. here my "prefered" one:
There are many ways. here my "preferred" one:
```
py -m pip install git+https://github.com/The-CJ/osu_irc.py.git#egg=osu_irc
```
Expand All @@ -20,7 +20,7 @@ import osu_irc
class MyBot(osu_irc.Client):

async def onReady(self):
self.joinChannel("#osu")
await self.joinChannel("#osu")
#do something

async def onMessage(self, message):
Expand All @@ -33,4 +33,4 @@ x = MyBot(token="1234567890", nickname="cool_username")
x.run()
```
Get nickname and server password(token) from here: https://osu.ppy.sh/p/irc
:copyright: 2018-2020 The_CJ
:copyright: 2018-2021 The_CJ
29 changes: 15 additions & 14 deletions osu_irc/Classes/channel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Dict, NewType, Set, List, TYPE_CHECKING
UserName = NewType("UserName", str)
from typing import Dict, NewType, Set, List, TYPE_CHECKING, Union, Optional
if TYPE_CHECKING:
from .client import Client as OsuClient

from .user import User
from .stores import UserStore
from .undefined import UNDEFINED

UserName = NewType("UserName", str)

class Channel(object):
"""
Expand All @@ -20,29 +20,29 @@ def __repr__(self):
def __str__(self):
return self.name or ""

def __init__(self, *x, **xx):
def __init__(self, *_, **__):

# props
self._name:str = UNDEFINED
self._chatters:Dict[UserName, User] = UserStore()
self._name:Optional[str] = None
self._chatters:Dict[Union[UserName, str], User] = UserStore()

# other
self.motd:str = ""

# because of user stores, we save the name of the different user types in a channel
# Update: sooo... em, yeah, in osu there are no IRC- Owner (~), Operator (&) or Helper (%)
# the Owner whould be BanchBot, i guess, but technicly these 3 could be taken out, but i don't give a fuck. REEEEEE
# Update: so... em, yeah, in osu there are no IRC- Owner (~), Operator (&) or Helper (%)
# the Owner would be BanchBot, i guess, but technically these 3 could be taken out, but i don't give a fuck. REEEEEE
self._owner:Set[str] = set() # ~
self._admin:Set[str] = set() # @
self._operator:Set[str] = set() # &
self._helper:Set[str] = set() # %
self._voiced:Set[str] = set() # +

# other than twitch, this class doesn't has a build function,
# because it should only be created by a handler (probl. mostly handleJoin)
# because it should only be created by a handler (probably. mostly handleJoin)

def compact(self) -> dict:
d:dict = {}
d:dict = dict()
d["name"] = self.name
d["motd"] = self.motd
d["chatters"] = self.chatters
Expand Down Expand Up @@ -72,7 +72,7 @@ def getViewer(self, **search:dict) -> User or None:
def getOwners(self) -> List[User]:
"""
get all users that are owner (~) of the current channel.
(NOTE: i never find any in thie result... but maybe there are owner... i mean BanchoBot Should be one, right?)
(NOTE: i never find any in the result... but maybe there are owner... i mean BanchoBot Should be one, right?)
"""

owners:List[User] = []
Expand Down Expand Up @@ -149,7 +149,7 @@ async def sendMessage(self, cls:"OsuClient", content:str) -> None:
Send a message to the channel,
requires you to give this function the Client class, don't ask why...
this is basicly an alternative to:
this is basically an alternative to:
cls.sendMessage(Channel.name, content)
makes you think... is this even faster? i dunno, adding it anyways LULW
Expand All @@ -158,10 +158,11 @@ async def sendMessage(self, cls:"OsuClient", content:str) -> None:

# props
@property
def chatters(self) -> Dict[UserName, User]:
def chatters(self) -> Dict[Union[UserName, str], User]:
return self._chatters

@property
def users(self) -> Dict[UserName, User]:
def users(self) -> Dict[Union[UserName, str], User]:
return self.chatters

@property
Expand Down
Loading

0 comments on commit 5f4b1c7

Please sign in to comment.