• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python bot.Bot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中slackbot.bot.Bot的典型用法代码示例。如果您正苦于以下问题:Python Bot类的具体用法?Python Bot怎么用?Python Bot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Bot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    pid = os.getpid()
    f = open(os.getcwd() + '/slackbot.pid', 'w')
    f.write(str(pid))
    f.close()
    bot = Bot()
    bot.run()
开发者ID:swirhen,项目名称:swirhen,代码行数:7,代码来源:run.py


示例2: slackbot_init

def slackbot_init():
    """
    Thread target for initializing slackbot
    """
    logger.info('Initializing slackbot')
    bot = Bot()
    bot.run()
开发者ID:phospodka,项目名称:slackhub,代码行数:7,代码来源:slackhubbot.py


示例3: main

def main():
    from slackbot import settings
    from slackbot.bot import Bot

    from .plugins.weather import OpenWeatherMap
    settings.open_weather_map = OpenWeatherMap()

    bot = Bot()
    bot.run()
开发者ID:t2y,项目名称:mybot,代码行数:9,代码来源:__main__.py


示例4: main

def main():
    kw = {
        "format": "[%(asctime)s] %(message)s",
        "datefmt": "%m/%d/%Y %H:%M:%S",
        "level": logging.DEBUG if settings.DEBUG else logging.INFO,
        "stream": sys.stdout,
    }
    logging.basicConfig(**kw)
    logging.getLogger("requests.packages.urllib3.connectionpool").setLevel(logging.WARNING)
    bot = Bot()
    bot.run()
开发者ID:cypreess,项目名称:slack-mancala-master,代码行数:11,代码来源:run.py


示例5: main

def main():
    """Then main Bot application"""
    if not conf.API_TOKEN or not conf.SPEAKER_IP:
        print(
            "Slack API token or Sonos speaker IP not set.\n"
            "Please add configure it before running Sonlack. Exiting..."
        )
        sys.exit(0)
    bot = Bot()
    print("Sonlack is rocking now. Enjoy your favorite music...")
    bot.run()
开发者ID:codeadict,项目名称:sonlack,代码行数:11,代码来源:robot.py


示例6: main

def main():
    try:
        settings.zendesk_class = Zendesk(
            settings.ZENDESK_APP,
            settings.ZENDESK_USER,
            settings.ZENDESK_PASS,
            )
    except AttributeError:
        print('Missing SLACKBOT_ZENDESK_APP, SLACKBOT_ZENDESK_USER or SLACKBOT_ZENDESK_PASS environment variable')
        sys.exit(1)

    print("starting bot...")
    bot = Bot()
    bot.run()
开发者ID:kotnik,项目名称:slack-zendesker,代码行数:14,代码来源:main.py


示例7: VBot

class VBot(object):

  def __init__(self):
    logging.info('initializing')
    self.bot = Bot()
    self.dispatcher = Dispatcher()
    logging.info('initialization finished')

  def run(self):
    logging.info('starting bot')
    self.bot.run()

  def answer(self, message, query):
    self.dispatcher.dispatch(message, query)
开发者ID:vzhong,项目名称:vvbot,代码行数:14,代码来源:bot.py


示例8: main

def main():
	global snakebot_config
	logging.basicConfig()
	curr_dir = os.path.dirname(os.path.realpath(__file__))
	sys.path.append(curr_dir)

	snakebot_config = ConfigParser.ConfigParser()
	snakebot_config.read("config.ini")

	settings.API_TOKEN = snakebot_config.get("slack", "API_TOKEN")

	settings.PLUGINS = ["snakebot"] #Overwrites other plugins. Don't need upload for instance.
	bot = Bot()
	print "[[ Snakebot online ]]"
	bot.run()
开发者ID:James-Firth,项目名称:Snakebot,代码行数:15,代码来源:runbot.py


示例9: main

def main():
    logger = logging.getLogger()
    handler = logging.StreamHandler()
    formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.setLevel(logging.DEBUG)

    sys.path.append("plugins")

    if 'SLACKBOT_API_TOKEN' not in os.environ:
        print "'SLACKBOT_API_TOKEN' environment variable not set. Exiting..."
        exit(1)

    bot = Bot()
    bot.run()
开发者ID:slowbluecamera,项目名称:resin-slackbot,代码行数:16,代码来源:run.py


示例10: main

def main():
    try:
        settings.jira_class = JiraWrapper(
            settings.JIRA_SERVER,
            settings.JIRA_PROJECTS,
            settings.JIRA_USERNAME,
            settings.JIRA_PASSWORD,
            )
        settings.ALLOWED_PROJECTS = settings.JIRA_PROJECTS.split(',')
        settings.ALLOWED_PROJECTS = [project.upper() for project in settings.ALLOWED_PROJECTS]
    except AttributeError:
        print('Missing JIRA_SERVER, JIRA_PROJECTS, JIRA_USERNAME or JIRA_PASSWORD environment variable')
        sys.exit(1)

    print("starting bot...")
    bot = Bot()
    bot.run()
开发者ID:mrkschan,项目名称:slack-jirer,代码行数:17,代码来源:main.py


示例11: main

def main():
	global lunchotron_config
	logging.basicConfig()
	curr_dir = os.path.dirname(os.path.realpath(__file__))
	sys.path.append(curr_dir)

	lunchotron_config = ConfigParser.ConfigParser()
	lunchotron_config.read("config.ini")

	settings.API_TOKEN = lunchotron_config.get("slack", "API_TOKEN")
	settings.gPlaces = GooglePlaces(lunchotron_config.get("google-places", "API_TOKEN"))
	settings.gmaps = googlemaps.Client(lunchotron_config.get("google-places", "API_TOKEN"))
	settings.location = lunchotron_config.get("google-places", "location")

	settings.PLUGINS = ["lunchotron"] #Overwrites other plugins. Don't need upload for instance.
	bot = Bot()
	print "[[ lunchotron online ]]"
	bot.run()
开发者ID:James-Firth,项目名称:Lunchotron,代码行数:18,代码来源:runbot.py


示例12: main

def main():
    try:
        settings.jira_class = JiraWrapper(
            settings.JIRA_SERVER,
            settings.JIRA_USERNAME,
            settings.JIRA_PASSWORD,
            )
        settings.ALLOWED_PROJECTS = settings.JIRA_PROJECTS.split(',')
        settings.ALLOWED_PROJECTS = [project.upper() for project in settings.ALLOWED_PROJECTS]
    except AttributeError:
        print('Missing JIRA_SERVER, JIRA_PROJECTS, JIRA_USERNAME or JIRA_PASSWORD environment variable')
        sys.exit(1)

    # Jira allows a limited number of queries, but jira module we are using is
    # not giving us that info. So we cache.
    settings.CACHE = ExpiringDict(max_len=500, max_age_seconds=30)

    print("starting bot...")
    bot = Bot()
    bot.run()
开发者ID:kotnik,项目名称:slack-jirer,代码行数:20,代码来源:main.py


示例13: __init__

    def __init__(self):
        logging.basicConfig(level=logging.INFO)
        self.muted_rooms = set()

        self.handlers = {}
        self.plugins = []
        if 'PLUGINS' in os.environ:
            self._load_plugins(map(
                str.strip,
                os.environ['PLUGINS'].split(',')
            ))
        self.bot = Bot()
开发者ID:Achiel,项目名称:creep,代码行数:12,代码来源:creep.py


示例14: Creep

class Creep():

    def __init__(self):
        logging.basicConfig(level=logging.INFO)
        self.muted_rooms = set()

        self.handlers = {}
        self.plugins = []
        if 'PLUGINS' in os.environ:
            self._load_plugins(map(
                str.strip,
                os.environ['PLUGINS'].split(',')
            ))
        self.bot = Bot()
#        for k, v in self.bot._client.channels.iteritems():
#            if 'name' in v and v['name'] == 'creep':
#                self.bot._client.send_message(
#                    k, 'Creep reporting for duty!'
#                )

    def mute(self, room_id, timeout=10):
        def unmute_room():
            self.unmute(room_id)

        self.muted_rooms.add(room_id)
        Timer(timeout, unmute_room).start()

    def unmute(self, room_id):  # TODO
        if room_id in self.muted_rooms:
            self.muted_rooms.remove(room_id)
            self.bot._client.send_message(
                room_id, "I'm back baby!"
            )

    def run(self):
        self.bot.run()

    def handle_message(self, message):
        body = message.body['text']
        command = body.split(' ')[0] if ' ' in body else body
        params = body[body.find(" ")+1:] if ' ' in body else None
        logging.info("incoming message '%s'" % body)
        if command in self.handlers:
            handler = self.handlers[command]
            try:
                try:
                    chan = message.channel
                except KeyError:
                    chan = None
                result = handler(message=params, origin=chan)
                message.reply(result)
            except Exception:
                logging.exception("Couldn't handle command '%s': " % command)
                message.reply("Sorry, I got into trouble")
        else:
            message.reply(
                "Unknown command: '%s'. "
                'Run "help" for more info on available commands.' % body
            )

    def shutdown(self):
        for plugin in self.plugins:
            plugin.shutdown()

    def _load_plugins(self, names):
        for name in names:
            try:
                self._load_plugin(name)
            except Exception:
                logging.exception("Couldn't load plugin '%s':" % name)

    def _load_plugin(self, name):
        '''
        assumes there's only one class per plugin
        '''
        plugin = __import__('plugins.%s' % name, fromlist=['plugins', ])
        plugin_instance = None
        for attribute in dir(plugin):
            item = getattr(plugin, attribute)
            if (inspect.isclass(item) and
                    issubclass(item, Plugin) and
                    not item == Plugin):
                plugin_instance = item(self)
                for handler_name in item.provides:
                    if handler_name in self.handlers.keys():
                        raise Exception("Can't load '%s': handler already "
                                        "registered for '%s'" % (name,
                                                                 handler_name))

                    self.handlers[handler_name] = _get_handler(handler_name,
                                                               plugin_instance)

                self.plugins.append(plugin_instance)
                logging.info("Finished loading '%s' plugin" % plugin_instance)
开发者ID:Achiel,项目名称:creep,代码行数:94,代码来源:creep.py


示例15: main

def main():
    bot = Bot()
    bot.run()
开发者ID:CampbellGroup,项目名称:common,代码行数:3,代码来源:run.py


示例16: __init__

 def __init__(self):
   logging.info('initializing')
   self.bot = Bot()
   self.dispatcher = Dispatcher()
   logging.info('initialization finished')
开发者ID:vzhong,项目名称:vvbot,代码行数:5,代码来源:bot.py


示例17: Bot

#coding: utf-8
#仮想通貨の価格をお知らせするslackbot
from slackbot.bot import Bot

bot = Bot()
bot.run()
开发者ID:haretaro,项目名称:coinbot,代码行数:6,代码来源:run.py


示例18: main

def main():
    bot = Bot()
    print("*running*")
    bot.run()
开发者ID:owocki,项目名称:emojibot,代码行数:4,代码来源:run.py


示例19: main

def main():
    logging.basicConfig(level=logging.DEBUG)
    bot = Bot()
    bot.run()
开发者ID:cmurtaugh,项目名称:tlt-bot,代码行数:4,代码来源:tlt_bot.py


示例20: main

def main():
    bot = Bot()
    print "Carebot is running. Invite it to a channel to begin."
    bot.run()
开发者ID:thecarebot,项目名称:carebot,代码行数:4,代码来源:carebot.py



注:本文中的slackbot.bot.Bot类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python slackclient.SlackClient类代码示例发布时间:2022-05-27
下一篇:
Python quoting.quote_ident函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap