|
| 1 | +# - AthenaTwitchBot - |
| 2 | +[](https://pypi.org/project/AthenaTwitchBot/) [](https://github.com/DirectiveAthena/VerSC-AthenaColor/blob/master/LICENSE) [](https://discord.gg/6JcDbhXkCH) [](https://pepy.tech/project/athenatwitchbot) |
| 3 | + |
| 4 | +--- |
| 5 | +## Package Details |
| 6 | +#### Details and features |
| 7 | +- A library to connect to the Twitch IRC system for a chatbot to utilize |
| 8 | +- Isn't dependent on 3rd party packages, except for those that have been created by [@AndreasSas](https://github.com/AndreasSas) |
| 9 | + - These can be designated by the leading "*Athena*..." |
| 10 | + - These packages aren't seen as a 3rd party dependency as they are all made by the "same party" |
| 11 | + |
| 12 | +#### Python Version |
| 13 | +- Supported Python versions: **3.10** |
| 14 | + - Other older versions of Python are not currently supported. |
| 15 | + - These older versions will probably not be supported by [@AndreasSas](https://github.com/AndreasSas) himself, but if you want to contribute to the project and make this package compatible with older versions of Python, Pull requests are always welcome. |
| 16 | + |
| 17 | +--- |
| 18 | +## Quick Example |
| 19 | +The following example is a working bot, but currently only meant as proof of work as the package is still in its early stages of being developed and needs some heavy tuning. |
| 20 | + |
| 21 | +Stay tuned for updates while we work on this on [stream](https://www.twitch.tv/directiveathena) or come hang out in the [discord](https://discord.com/invite/6JcDbhXkCH). |
| 22 | + |
| 23 | +```python |
| 24 | +# --- Imports --- |
| 25 | +import AthenaTwitchBot # Main import for the bot to work |
| 26 | +import AthenaColor # Not needed for the following example, but is a dependency |
| 27 | +import AthenaLib # Not needed for the following example, but is a dependency |
| 28 | + |
| 29 | +# --- Twitch bot --- |
| 30 | +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 | + |
| 56 | +# --- Main function --- |
| 57 | +def main(): |
| 58 | + AthenaTwitchBot.launch( |
| 59 | + bot=newBot(), |
| 60 | + ssl=True # set to true to enable ssl connection to Twitch |
| 61 | + ) |
| 62 | + |
| 63 | +if __name__ == '__main__': |
| 64 | + main() |
| 65 | + |
| 66 | +``` |
| 67 | + |
| 68 | +--- |
| 69 | +## Documentation |
| 70 | +Full documentation can be found at: |
| 71 | +**[directiveathena.com/docu](https://publish.obsidian.md/directiveathena/)** (redirect to Obsidian.md publish site) |
| 72 | +(Reminder, the documentation is still under heavy development) |
| 73 | + |
| 74 | +--- |
| 75 | +## Install |
| 76 | +To install the package in your Python environment |
| 77 | + |
| 78 | +``` |
| 79 | +pip install AthenaTwitchBot --upgrade |
| 80 | +``` |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## Links |
| 85 | +Project files can be found at: |
| 86 | +- [GitHub Repo](https://github.com/DirectiveAthena/AthenaTwitchBot) |
| 87 | +- [Pypi link](https://pypi.org/project/AthenaTwitchBot/) |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Disclaimer |
| 92 | +With *No Dependency*, the standard library is not counted as a dependency |
| 93 | + |
| 94 | +--- |
| 95 | +Made By Andreas Sas,` 2022` |
0 commit comments