Initial commit
This commit is contained in:
parent
023fd7d76a
commit
4406d9003f
|
@ -1,3 +1,9 @@
|
||||||
|
# Application specific
|
||||||
|
abots-git/
|
||||||
|
abots/
|
||||||
|
abots
|
||||||
|
*.log
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
19
README.md
19
README.md
|
@ -1,3 +1,20 @@
|
||||||
# irc
|
# irc
|
||||||
|
|
||||||
The IRC component
|
The IRC component
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
* abots
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Install abots using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
$ git clone https://tildegit.org/aewens/abots _abots
|
||||||
|
$ mv _abots/abots .
|
||||||
|
$ rm -rf _abots
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/opt/abots/env/bin/python3
|
||||||
|
|
||||||
|
from abots.net import IRCSocketClient
|
||||||
|
from abots.helpers import Logger, infinitedict, isnumeric
|
||||||
|
from time import sleep
|
||||||
|
from os import remove as delete_file
|
||||||
|
from os.path import isfile
|
||||||
|
|
||||||
|
logname = "babili_irc_client"
|
||||||
|
logfile = f"{logname}.log"
|
||||||
|
if isfile(logfile):
|
||||||
|
delete_file(logfile)
|
||||||
|
settings = infinitedict()
|
||||||
|
settings["file"]["formatter"] = "%(message)s"
|
||||||
|
settings["stream"]["formatter"] = "%(message)s"
|
||||||
|
logger = Logger(logname, settings=settings)
|
||||||
|
logger.start()
|
||||||
|
|
||||||
|
irc_host = "localhost"
|
||||||
|
irc_port = 6667
|
||||||
|
irc_timeout = 3
|
||||||
|
|
||||||
|
irc_client = IRCSocketClient(irc_host, irc_port, daemon=True)#, timeout=irc_timeout)
|
||||||
|
irc_client.start()
|
||||||
|
inbox = irc_client.queues.get("inbox")
|
||||||
|
outbox = irc_client.queues.get("outbox")
|
||||||
|
events = irc_client.queues.get("events")
|
||||||
|
|
||||||
|
#sleep(2)
|
||||||
|
irc_client.ready.wait()
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
:center.tilde.chat NOTICE * :*** Looking up your hostname...
|
||||||
|
:center.tilde.chat NOTICE * :*** Could not resolve your hostname: Domain not found; using your IP address (127.0.0.1) instead.
|
||||||
|
:center.tilde.chat CAP * LS :account-notify account-tag away-notify batch cap-notify chghost echo-message extended-join invite-notify message-tags sasl server-time
|
||||||
|
:center.tilde.chat 001 babili|test :Welcome to the tilde.chat IRC Network babili|test!babili|test@127.0.0.1
|
||||||
|
:center.tilde.chat 002 babili|test :Your host is center.tilde.chat, running version InspIRCd-3
|
||||||
|
:center.tilde.chat 003 babili|test :This server was created 17:19:44 May 06 2019
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def parse(message):
|
||||||
|
prefix, command, params = message.lstrip(":").rstrip("\r\n").split(" ", 2)
|
||||||
|
meta = dict()
|
||||||
|
meta["source"] = "nick" if "!" in prefix else "server"
|
||||||
|
meta["type"] = "numeric" if isnumeric(command) else "alpha"
|
||||||
|
return meta
|
||||||
|
|
||||||
|
name = "babili"
|
||||||
|
first = False
|
||||||
|
server = None
|
||||||
|
irc_client.send("CAP LS")
|
||||||
|
irc_client.send("CAP END")
|
||||||
|
irc_client.send(f"USER {name} - - -")
|
||||||
|
irc_client.send(f"NICK {name}")
|
||||||
|
while True:
|
||||||
|
for letter in irc_client.recv():
|
||||||
|
if letter is not None:# or len(letter) > 0:
|
||||||
|
#meta = parse(letter)
|
||||||
|
#print(meta)
|
||||||
|
#source = meta["source"]
|
||||||
|
#if not first and source == "server":
|
||||||
|
# server = source
|
||||||
|
# first = True
|
||||||
|
#elif context == server and command == "CAP":
|
||||||
|
logger.debug(letter)
|
||||||
|
sleep(1)
|
||||||
|
#for letter in irc_client.recv():
|
||||||
|
# if letter is not None:
|
||||||
|
# logger.debug(letter)
|
||||||
|
irc_client.stop()
|
Loading…
Reference in New Issue