Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 5a90fb2

Browse files
authored
Merge pull request #12 from DirectiveAthena/v0.6.0_Proposal
V0.6.0 proposal
2 parents 97ec5b7 + ff224b9 commit 5a90fb2

34 files changed

+820
-498
lines changed

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,40 @@ import AthenaLib # Not needed for the following example, but is a depende
2828

2929
# --- Twitch bot ---
3030
class newBot(AthenaTwitchBot.TwitchBot):
31-
def __init__(self):
32-
super(newBot, self).__init__(
33-
# Make sure you fill in the fields below
34-
# else the bot will not be able to be authenticated by Twitch
35-
nickname="...", # <--- The registered bot name
36-
oauth_token="...", # <--- the registered bots access token. Don't put this in plain text!
37-
channel="...", # <--- The twitch channel name you want to bind your bot to
38-
prefix="!", # <--- The "default" prefix is an exclamation point, but technically you can assign any string as a prefix
39-
)
40-
41-
# - Command -
42-
# A command is only ran when it is invoked by a user in chat
43-
# In the following case this would be by typing "!ping" in chat
44-
@AthenaTwitchBot.command_method(name="ping")
45-
def command_ping(self, context: AthenaTwitchBot.TwitchMessageContext):
46-
context.reply("pong!") # a "context.reply" function will reply to the user whi invoked the command
47-
48-
# - Task -
49-
# A task is run automatically every "delay" amount of seconds
50-
# In the following case, the method will be run every minute
51-
# The "before" kwarg will
52-
@AthenaTwitchBot.scheduled_task_method(delay=60, before=True)
53-
def task_post_github(self, context: AthenaTwitchBot.TwitchMessageContext):
54-
context.write(f"This bot is made possible by: https://github.com/DirectiveAthena/AthenaTwitchBot")
55-
31+
def __init__(self):
32+
super(newBot, self).__init__(
33+
# Make sure you fill in the fields below
34+
# else the bot will not be able to be authenticated by Twitch
35+
nickname="...", # <--- The registered bot name
36+
oauth_token="...", # <--- the registered bots access token. Don't put this in plain text!
37+
channel="...", # <--- The twitch channel name you want to bind your bot to
38+
prefix="!", # <--- The "default" prefix is an exclamation point, but technically you can assign any string as a prefix
39+
)
40+
41+
# - Command -
42+
# A command is only ran when it is invoked by a user in chat
43+
# In the following case this would be by typing "!ping" in chat
44+
@AthenaTwitchBot.command_method(name="ping")
45+
def command_ping(self, context: AthenaTwitchBot.TwitchMessageContext):
46+
context.reply("pong!") # a "context.reply" function will reply to the user whi invoked the command
47+
48+
# - Task -
49+
# A task is run automatically every "delay" amount of seconds
50+
# In the following case, the method will be run every minute
51+
# The "wait_before" kwarg defines if the asyncio.sleep runs before or after the first call of the callback
52+
@AthenaTwitchBot.scheduled_task_method(delay=60, wait_before=True)
53+
def task_post_github(self, context: AthenaTwitchBot.TwitchMessageContext):
54+
context.write(f"This bot is made possible by: https://github.com/DirectiveAthena/AthenaTwitchBot")
55+
5656
# --- Main function ---
5757
def main():
58-
AthenaTwitchBot.launch(
59-
bot=newBot(),
60-
ssl=True # set to true to enable ssl connection to Twitch
61-
)
58+
AthenaTwitchBot.launch(
59+
bot=newBot(),
60+
ssl=True # set to true to enable ssl connection to Twitch
61+
)
6262

6363
if __name__ == '__main__':
64-
main()
64+
main()
6565

6666
```
6767

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def readme_handler() -> str:
1818

1919
def version_handler() -> str:
2020
# ------------------------------------------------------------------------------------------------------------------
21-
version = 0,5,0 # <-- DEFINE THE VERSION IN A TUPLE FORMAT HERE
21+
version = 0,6,0 # <-- DEFINE THE VERSION IN A TUPLE FORMAT HERE
2222
# ------------------------------------------------------------------------------------------------------------------
2323
version_str = ".".join(str(i) for i in version)
2424

src/AthenaTwitchBot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from AthenaTwitchBot.models.twitch_bot import TwitchBot
88
from AthenaTwitchBot.models.twitch_bot_protocol import TwitchBotProtocol
9-
from AthenaTwitchBot.models.twitch_message_context import TwitchMessageContext
9+
from AthenaTwitchBot.models.twitch_context import TwitchContext
1010

1111
from AthenaTwitchBot.functions.launch import launch
1212

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +0,0 @@
1-
# ----------------------------------------------------------------------------------------------------------------------
2-
# - Package Imports -
3-
# ----------------------------------------------------------------------------------------------------------------------
4-
# General Packages
5-
from __future__ import annotations
6-
7-
# Custom Library
8-
9-
# Custom Packages
10-
11-
# ----------------------------------------------------------------------------------------------------------------------
12-
# - Code -
13-
# ----------------------------------------------------------------------------------------------------------------------

src/AthenaTwitchBot/_info/_v.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION='0.5.0'
1+
VERSION='0.6.0'
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +0,0 @@
1-
# ----------------------------------------------------------------------------------------------------------------------
2-
# - Package Imports -
3-
# ----------------------------------------------------------------------------------------------------------------------
4-
# General Packages
5-
from __future__ import annotations
6-
7-
# Custom Library
8-
9-
# Custom Packages
10-
11-
# ----------------------------------------------------------------------------------------------------------------------
12-
# - Code -
13-
# ----------------------------------------------------------------------------------------------------------------------
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ----------------------------------------------------------------------------------------------------------------------
2+
# - Package Imports -
3+
# ----------------------------------------------------------------------------------------------------------------------
4+
# General Packages
5+
from __future__ import annotations
6+
from typing import Callable
7+
8+
# Custom Library
9+
from AthenaColor import HEX
10+
11+
# Custom Packages
12+
13+
# ----------------------------------------------------------------------------------------------------------------------
14+
# - Code -
15+
# ----------------------------------------------------------------------------------------------------------------------
16+
MESSAGE_TAG_MAPPING:dict[str:Callable] = {
17+
"@badge-info": "badge_info",
18+
"badges": "badges",
19+
"client-nonce": "client_nonce",
20+
"color": "color",
21+
"display-name": "display_name",
22+
"emotes": "emotes",
23+
"first-msg": "first_msg",
24+
"flags": "flags",
25+
"id": "message_id",
26+
"mod": "mod",
27+
"room-id": "room_id",
28+
"subscriber": "subscriber",
29+
"tmi-sent-ts": "tmi_sent_ts",
30+
"turbo": "turbo",
31+
"user-id": "user_id",
32+
"user-type": "user_type",
33+
"reply-parent-display-name": "reply_parent_display_name",
34+
"reply-parent-msg-body": "reply_parent_msg_body",
35+
"reply-parent-msg-id": "reply_parent_msg_id",
36+
"reply-parent-user-id": "reply_parent_user_id",
37+
"reply-parent-user-login": "reply_parent_user_login",
38+
"emote-only": "emote_only",
39+
}
40+
41+
MESSAGE_TAG_CONVERSION_MAPPING:dict[str:Callable] = {
42+
"@badge-info": lambda value: value,
43+
"badges": lambda value: value,
44+
"client-nonce": lambda value: value,
45+
"color": lambda value: HEX(value) if value else HEX(),
46+
"display-name": lambda value: value,
47+
"emotes": lambda value: value,
48+
"first-msg": lambda value: bool(int(value)),
49+
"flags": lambda value: value,
50+
"id": lambda value: value,
51+
"mod": lambda value: bool(int(value)),
52+
"room-id": lambda value: value,
53+
"subscriber": lambda value: bool(int(value)),
54+
"tmi-sent-ts": lambda value: int(value),
55+
"turbo": lambda value: bool(int(value)),
56+
"user-id": lambda value: int(value),
57+
"user-type": lambda value: value,
58+
"reply-parent-display-name":lambda value: value,
59+
"reply-parent-msg-body": lambda value: value,
60+
"reply-parent-msg-id": lambda value: int(value),
61+
"reply-parent-user-id": lambda value: int(value),
62+
"reply-parent-user-login": lambda value: value,
63+
"emote-only": lambda value: bool(int(value)),
64+
}

src/AthenaTwitchBot/models/wrapper_helpers/__init__.py renamed to src/AthenaTwitchBot/data/general.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
# ----------------------------------------------------------------------------------------------------------------------
1212
# - Code -
1313
# ----------------------------------------------------------------------------------------------------------------------
14+
EMPTY_STR = ""
15+
ZERO = 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ----------------------------------------------------------------------------------------------------------------------
2+
# - Package Imports -
3+
# ----------------------------------------------------------------------------------------------------------------------
4+
# General Packages
5+
from __future__ import annotations
6+
7+
# Custom Library
8+
9+
# Custom Packages
10+
11+
# ----------------------------------------------------------------------------------------------------------------------
12+
# - All -
13+
# ----------------------------------------------------------------------------------------------------------------------
14+
__all__ = [
15+
"PING_RECEIVED"
16+
]
17+
18+
# ----------------------------------------------------------------------------------------------------------------------
19+
# - Code -
20+
# ----------------------------------------------------------------------------------------------------------------------
21+
PING_RECEIVED = "PING RECEIVED"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ----------------------------------------------------------------------------------------------------------------------
2+
# - Package Imports -
3+
# ----------------------------------------------------------------------------------------------------------------------
4+
# General Packages
5+
from __future__ import annotations
6+
7+
# Custom Library
8+
9+
# Custom Packages
10+
11+
# ----------------------------------------------------------------------------------------------------------------------
12+
# - All -
13+
# ----------------------------------------------------------------------------------------------------------------------
14+
__all__ = [
15+
"NICK", "PASS", "JOIN", "PONG", "REQUEST_COMMANDS", "REQUEST_MEMBERSHIP", "REQUEST_TAGS", "PING", "PRIVMSG",
16+
"TMI_TWITCH_TV", "CAP", "ACK", "ASTERISK", "TWITCH_TAGS", "EQUALS"
17+
]
18+
19+
# ----------------------------------------------------------------------------------------------------------------------
20+
# - Code -
21+
# ----------------------------------------------------------------------------------------------------------------------
22+
NICK = "NICK"
23+
PASS = "PASS oauth:"
24+
JOIN = "JOIN"
25+
PONG = "PONG"
26+
REQUEST_COMMANDS = "CAP REQ :twitch.tv/commands"
27+
REQUEST_MEMBERSHIP = "CAP REQ :twitch.tv/membership"
28+
REQUEST_TAGS = "CAP REQ :twitch.tv/tags"
29+
PING = "PING"
30+
PRIVMSG = "PRIVMSG"
31+
TMI_TWITCH_TV = ":tmi.twitch.tv"
32+
CAP = "CAP"
33+
ASTERISK = "*"
34+
ACK = "ACK"
35+
TWITCH_TAGS = ":twitch.tv/tags"
36+
EQUALS = "="

0 commit comments

Comments
 (0)