Movatterモバイル変換


[0]ホーム

URL:


 / 
Telegram-Bot-0.027
River stage one • 2 direct dependents • 2 total dependents
/Telegram::Bot

NAME

Telegram::Bot - A base class to make your very own Telegram bot

VERSION

version 0.027

SYNOPSIS

NOTE: This API should not yet be considered stable.

Creating a bot is easy:

package MyBot;use Mojo::Base 'Telegram::Bot::Brain';has token => 'YOURTOKENHERE';# send a polite reply, to either a group or a single user,# depending on where we were addressed fromsub _be_polite {  my ($self, $msg) = @_;  return unless $msg->text =~ /hello/;  # is this a 1-on-1 ?  if ($msg->chat->is_user) {    $msg->reply("hello there");    # send them a picture as well    $self->sendPhoto({chat_id => $msg->chat->id, photo => $image_filename});  }  # group chat  else {    $msg->reply("hello to everyone!");  }}# setup our botsub init {  my $self = shift;  $self->add_listener(\&_be_polite);}1;

Now just:

perl -MMyBot -E 'MyBot->new->think'

and you've got yourself a stew, baby! Or a bot, anyway.

Note that for the bot to see messages that do not start with a leading '/', you will need to use the'/setprivacy' command on Telegram's@botfather interface to change the privacy settings.

EXAMPLES

This distribution'sex/ directory contains some complete examples that may be instructive to look at.

AUTHORS

  • Justin Hawkins <justin@eatmorecode.com>

  • James Green <jkg@earth.li>

  • Julien Fiegehenn <simbabque@cpan.org>

  • Jess Robinson <jrobinson@cpan.org>

  • Albert Cester <albert.cester@web.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by James Green.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Module Install Instructions

To install Telegram::Bot, copy and paste the appropriate command in to your terminal.

cpanm

cpanm Telegram::Bot

CPAN shell

perl -MCPAN -e shellinstall Telegram::Bot

For more information on module installation, please visitthe detailed CPAN module installation guide.

Keyboard Shortcuts

Global
sFocus search bar
?Bring up this help dialog
GitHub
gpGo to pull requests
gigo to github issues (only if github is preferred repository)
POD
gaGo to author
gcGo to changes
giGo to issues
gdGo to dist
grGo to repository/SCM
gsGo to source
gbGo to file browse
Search terms
module: (e.g.module:Plugin)
distribution: (e.g.distribution:Dancer auth)
author: (e.g.author:SONGMU Redis)
version: (e.g.version:1.00)

[8]ページ先頭

©2009-2025 Movatter.jp