diff --git a/LICENSE b/LICENSE
@@ -1,6 +1,6 @@
ISC License
-Copyright (c) 2023, acidvegas <acid.vegas@acid.vegas>
+Copyright (c) 2024, acidvegas <acid.vegas@acid.vegas>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/README.md b/README.md
@@ -1,5 +1,5 @@
## Information
-This is a basic skeleton for building your own bots for Internet Relay Chat usage. It is asyncronous, can log to file, handle basic I/O, flood control, etc.
+This is a basic skeleton for building your own bots for Internet Relay Chat *(IRC)* usage. It is asyncronous, can log to file, handle basic I/O, flood control, etc.
A skeleton in Python & Golang *(beta)* are in this repository.
@@ -14,5 +14,4 @@ Join **#dev** on **irc.supernets.org** for help building IRC bots frm scratch!
- **RFC7194** - [Default Port for Internet Relay Chat (IRC) via TLS/SSL](https://raw.githubusercontent.com/internet-relay-chat/archive/master/rfc/rfc7194.txt)
- [Numerics & Events](https://raw.githubusercontent.com/internet-relay-chat/archive/master/numerics.txt)
-###### Mirrors
-[acid.vegas](https://git.acid.vegas/skeleton) • [GitHub](https://github.com/acidvegas/skeleton) • [GitLab](https://gitlab.com/acidvegas/skeleton) • [SuperNETs](https://git.supernets.org/acidvegas/skeleton)
+###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/skeleton) • [SuperNETs](https://git.supernets.org/acidvegas/skeleton) • [GitHub](https://github.com/acidvegas/skeleton) • [GitLab](https://gitlab.com/acidvegas/skeleton) • [Codeberg](https://codeberg.org/acidvegas/skeleton)
diff --git a/skeleton.py b/skeleton.py
@@ -34,6 +34,7 @@ pink = '13'
grey = '14'
light_grey = '15'
+
def color(msg: str, foreground: str, background: str = None) -> str:
'''
Color a string with the specified foreground and background colors.
@@ -44,6 +45,7 @@ def color(msg: str, foreground: str, background: str = None) -> str:
'''
return f'\x03{foreground},{background}{msg}{reset}' if background else f'\x03{foreground}{msg}{reset}'
+
def ssl_ctx(verify: bool = False, cert_path: str = None, cert_pass: str = None) -> ssl.SSLContext:
'''
Create a SSL context for the connection.
@@ -57,6 +59,7 @@ def ssl_ctx(verify: bool = False, cert_path: str = None, cert_pass: str = None)
ctx.load_cert_chain(cert_path) if not cert_pass else ctx.load_cert_chain(cert_path, cert_pass)
return ctx
+
class Bot():
def __init__(self):
self.nickname = 'skeleton'
@@ -66,6 +69,7 @@ class Bot():
self.writer = None
self.last = time.time()
+
async def action(self, chan: str, msg: str):
'''
Send an ACTION to the IRC server.
@@ -75,6 +79,7 @@ class Bot():
'''
await self.sendmsg(chan, f'\x01ACTION {msg}\x01')
+
async def raw(self, data: str):
'''
Send raw data to the IRC server.
@@ -83,6 +88,7 @@ class Bot():
'''
self.writer.write(data[:510].encode('utf-8') + b'\r\n')
+
async def sendmsg(self, target: str, msg: str):
'''
Send a PRIVMSG to the IRC server.
@@ -92,6 +98,7 @@ class Bot():
'''
await self.raw(f'PRIVMSG {target} :{msg}')
+
async def connect(self):
'''Connect to the IRC server.'''
while True:
@@ -117,6 +124,7 @@ class Bot():
finally:
await asyncio.sleep(30) # Wait 30 seconds before reconnecting
+
async def eventPRIVMSG(self, data: str):
'''
Handle the PRIVMSG event.
@@ -152,6 +160,7 @@ class Bot():
await self.sendmsg(target, option)
self.last = time.time() # Update the last command time if it starts with ! character to prevent command flooding
+
async def handle(self, data: str):
'''
Handle the data received from the IRC server.
@@ -212,6 +221,8 @@ def setup_logger(log_filename: str, to_file: bool = False):
else:
logging.basicConfig(level=logging.NOTSET, handlers=(sh,))
+
+
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Connect to an IRC server.") # The arguments without -- are required arguments.
parser.add_argument("server", help="The IRC server address.")
diff --git a/skelly.go b/skelly.go
@@ -1,3 +1,5 @@
+// irc bot skeleton - developed by acidvegas in golang (https://git.acid.vegas/skeleton)
+
package main
import (
| | | |