-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
initial commit
1 parent
9221bcf
commit 0549f9d
Showing
6 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: "Lint" | ||
|
||
# yamllint disable-line rule:truthy | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint-yaml: | ||
name: "YAML" | ||
runs-on: ubuntu-22.04 | ||
env: | ||
YAML_FILES: | | ||
.github/workflows/lint.yml | ||
action.yml | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Dependencies | ||
run: sudo apt-get update && sudo apt-get install -y yamllint | ||
- name: Validate YAML Files | ||
run: yamllint $YAML_FILES | ||
|
||
lint-python: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: chartboost/ruff-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
# yamllint disable rule:line-length | ||
name: "Tests" | ||
|
||
# yamllint disable-line rule:truthy | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: run | ||
uses: "./" | ||
with: | ||
irc-server: "irc.hackint.org" | ||
irc-nickname: "workflow-test" | ||
irc-target: "#ffda-github-irc" | ||
message: "${{ github.head_ref }} ${{ github.sha }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# action-irc-message | ||
# action-irc-message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
# yamllint disable rule:line-length | ||
|
||
name: "Send message to IRC" | ||
inputs: | ||
irc-server: | ||
required: true | ||
irc-nickname: | ||
required: true | ||
irc-target: | ||
description: 'nickname or channel' | ||
required: true | ||
irc-port: | ||
default: 6697 | ||
message: | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
- name: Install Dependencies | ||
run: pip install irc | ||
shell: bash | ||
- name: Send message | ||
run: | | ||
python irc-message.py -p "${{ inputs.irc-port }}" "${{ inputs.irc-server }}" "${{ inputs.irc-nickname }}" "${{ inputs.irc-target }}" "${{ inputs.message }}" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#! /usr/bin/env python | ||
|
||
import sys | ||
import ssl | ||
import argparse | ||
|
||
import irc.client | ||
|
||
target = None | ||
"The nick or channel to which to send messages" | ||
message = None | ||
|
||
def on_connect(connection, event): | ||
if irc.client.is_channel(target): | ||
connection.join(target) | ||
return | ||
|
||
def on_join(connection, event): | ||
connection.privmsg(target, message) | ||
connection.quit("Bye") | ||
|
||
|
||
def on_disconnect(connection, event): | ||
raise SystemExit() | ||
|
||
|
||
def get_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('server') | ||
parser.add_argument('nickname') | ||
parser.add_argument('target', help="a nickname or channel") | ||
parser.add_argument('message') | ||
parser.add_argument('-p', '--port', default=6697, type=int) | ||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
global target | ||
global message | ||
|
||
args = get_args() | ||
target = args.target | ||
message = args.message | ||
|
||
ssl_factory = irc.connection.Factory(wrapper=ssl.wrap_socket) | ||
reactor = irc.client.Reactor() | ||
try: | ||
c = reactor.server().connect( | ||
args.server, args.port, args.nickname, connect_factory=ssl_factory | ||
) | ||
except irc.client.ServerConnectionError: | ||
print(sys.exc_info()[1]) | ||
raise SystemExit(1) | ||
|
||
c.add_global_handler("welcome", on_connect) | ||
c.add_global_handler("join", on_join) | ||
c.add_global_handler("disconnect", on_disconnect) | ||
|
||
reactor.process_forever() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |