mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-10-27 03:43:44 +00:00 
			
		
		
		
	change telegram default index to telegram-index
This commit is contained in:
		| @ -13,7 +13,7 @@ Wrapper for managing custom repository inspired by [repo-scripts](https://github | ||||
| * Multi-architecture support. | ||||
| * VCS packages support. | ||||
| * Sign support with gpg (repository, package, per package settings). | ||||
| * Synchronization to remote services (rsync, s3 and github) and report generation (html). | ||||
| * Synchronization to remote services (rsync, s3 and github) and report generation (email, html, telegram). | ||||
| * Dependency manager. | ||||
| * Ability to patch AUR packages and even create package from local PKGBUILDs. | ||||
| * Repository status interface with optional authorization and control options: | ||||
|  | ||||
| @ -124,6 +124,7 @@ Section name must be either `telegram` (plus optional architecture name, e.g. `t | ||||
| * `homepage` - link to homepage, string, optional. | ||||
| * `link_path` - prefix for HTML links, string, required. | ||||
| * `template_path` - path to Jinja2 template, string, required. | ||||
| * `template_type` - `parse_mode` to be passed to telegram API, one of `MarkdownV2`, `HTML`, `Markdown`, string, optional, default `HTML`. | ||||
|  | ||||
| ## `upload` group | ||||
|  | ||||
|  | ||||
| @ -46,7 +46,7 @@ ssl = disabled | ||||
| template_path = /usr/share/ahriman/templates/repo-index.jinja2 | ||||
|  | ||||
| [telegram] | ||||
| template_path = /usr/share/ahriman/templates/telegram.jinja2 | ||||
| template_path = /usr/share/ahriman/templates/telegram-index.jinja2 | ||||
|  | ||||
| [upload] | ||||
| target = | ||||
|  | ||||
| @ -1,10 +1,5 @@ | ||||
| {#simplified version of full report, now in markdown#} | ||||
| ## {{ repository }} update | ||||
|  | ||||
| {#simplified version of full report#} | ||||
| <b>{{ repository }} update</b> | ||||
| {% for package in packages %} | ||||
|     * [{{ package.name }}]({{ link_path }}/{{ package.filename }}) {{ package.version }} at {{ package.build_date }} | ||||
| <a href="{{ link_path }}/{{ package.filename }}">{{ package.name }}</a> {{ package.version }} at {{ package.build_date }} | ||||
| {% endfor %} | ||||
|  | ||||
| {% if homepage is not none %} | ||||
| [Repository]({{ homepage }}) | ||||
| {% endif %} | ||||
|  | ||||
							
								
								
									
										1
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								setup.py
									
									
									
									
									
								
							| @ -67,6 +67,7 @@ setup( | ||||
|             "package/share/ahriman/templates/build-status.jinja2", | ||||
|             "package/share/ahriman/templates/email-index.jinja2", | ||||
|             "package/share/ahriman/templates/repo-index.jinja2", | ||||
|             "package/share/ahriman/templates/telegram-index.jinja2", | ||||
|         ]), | ||||
|         ("share/ahriman/templates/build-status", [ | ||||
|             "package/share/ahriman/templates/build-status/login-modal.jinja2", | ||||
|  | ||||
| @ -38,6 +38,7 @@ class Telegram(Report, JinjaTemplate): | ||||
|     :ivar api_key: bot api key | ||||
|     :ivar chat_id: chat id to post message, either string with @ or integer | ||||
|     :ivar template_path: path to template for built packages | ||||
|     :ivar template_type: template message type to be used in parse mode, one of MarkdownV2, HTML, Markdown | ||||
|     """ | ||||
|  | ||||
|     TELEGRAM_API_URL = "https://api.telegram.org" | ||||
| @ -56,6 +57,7 @@ class Telegram(Report, JinjaTemplate): | ||||
|         self.api_key = configuration.get(section, "api_key") | ||||
|         self.chat_id = configuration.get(section, "chat_id") | ||||
|         self.template_path = configuration.getpath(section, "template_path") | ||||
|         self.template_type = configuration.get(section, "template_type", fallback="HTML") | ||||
|  | ||||
|     def _send(self, text: str) -> None: | ||||
|         """ | ||||
| @ -65,7 +67,7 @@ class Telegram(Report, JinjaTemplate): | ||||
|         try: | ||||
|             response = requests.post( | ||||
|                 f"{self.TELEGRAM_API_URL}/bot{self.api_key}/sendMessage", | ||||
|                 data={"chat_id": self.chat_id, "text": text}) | ||||
|                 data={"chat_id": self.chat_id, "text": text, "parse_mode": self.template_type}) | ||||
|             response.raise_for_status() | ||||
|         except requests.HTTPError as e: | ||||
|             self.logger.exception("could not perform request: %s", exception_response_text(e)) | ||||
|  | ||||
| @ -87,7 +87,7 @@ def test_fetch_new(mocker: MockerFixture) -> None: | ||||
|     local = Path("local") | ||||
|     Sources.fetch(local, "remote") | ||||
|     check_output_mock.assert_has_calls([ | ||||
|         mock.call("git", "clone", "remote", str(local), exception=None, logger=pytest.helpers.anyvar(int)), | ||||
|         mock.call("git", "clone", "remote", str(local), exception=None, cwd=local, logger=pytest.helpers.anyvar(int)), | ||||
|         mock.call("git", "checkout", "--force", Sources._branch, | ||||
|                   exception=None, cwd=local, logger=pytest.helpers.anyvar(int)), | ||||
|         mock.call("git", "reset", "--hard", f"origin/{Sources._branch}", | ||||
|  | ||||
| @ -20,7 +20,7 @@ def test_send(configuration: Configuration, mocker: MockerFixture) -> None: | ||||
|     report._send("a text") | ||||
|     request_mock.assert_called_once_with( | ||||
|         pytest.helpers.anyvar(str, strict=True), | ||||
|         data={"chat_id": pytest.helpers.anyvar(str, strict=True), "text": "a text"}) | ||||
|         data={"chat_id": pytest.helpers.anyvar(str, strict=True), "text": "a text", "parse_mode": "HTML"}) | ||||
|  | ||||
|  | ||||
| def test_send_failed(configuration: Configuration, mocker: MockerFixture) -> None: | ||||
|  | ||||
		Reference in New Issue
	
	Block a user